Category : class

Need help to initialize values in default constructor class A{ private: string name; int age; int id; public: A(string name,int age,int id); int getAge(); int getId(); } class B{ private: vector <A> a; int total; int length; public: B(); int getTotal(); int getLength(); } How to initialize the vector variable of class B in the ..

Read more

i have a class named String class String { private: char* chaine; } i want to create who an Overload operators + (for concatenation of strings) and = for assignments between strings so i don’t know thw suntax to declare exactly these operators is it like that String &operator=(String &S); String &operator+(String& S) Source: Windows ..

Read more

Is there any advantage of initializing data members of the class in a Non-Parameterized Constructor? Like, if it takes no parameters, initializing the class data members inside the Non-Parameterized constructor isn’t like initializing the values directly in class? Example: class persons { private: int age, id; public: persons(){ age = 2; id = 3; } ..

Read more