Answer to Question #348394 in C++ for m.ibrahim

Question #348394

create a class named programming.while creating an object of the class if nothing is passed to it then the message i love programming languages should be printed if some string is passed to it then in place of programming language the name of that string


1
Expert's answer
2022-06-07T08:16:09-0400
#include <iostream> 
#include <string>

using namespace std; 


class Programming
{
private:

	string s;

public:

	Programming()
	{
		cout << "I love programming languages";
	}

	Programming(string ss)
	{
		s = ss;
		cout << "I love " << s;
	}
};


int main( ) 
{ 
	Programming* pr = new Programming();
	cout << endl;
	Programming* pr1 = new Programming("C++");
	
	return 0; 
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS