I'm learning c++ and I have problem with basics. How to init object in different class?
For example I have code:
class A { private: static int num; static string val; public: A(int n, string w) { num = n; val = w; } }; I want to create object A in class B, so I have try like this:
class B { private: A objA; public: B(int numA, string valA){ objA = new LiczbaHeksA(numA, valA); } }; Different ways(same constructor):
public: B(A obA){ objA = obA; } or
public: B(int numA, string valA){ objA = A(numA, valA); } Always I'm getting error: No default constructor for exist for class "A". I've read that default constructor is constructor without any arguments, but I give them, so why it is searching default?