Object with argument as a class member

Write your question here.
I want to do something as below but the compiler is not allowing me to do.
There are three classes

1
2
3
4
5
6
7
8
9
10
11
Class A
{
};
Class B
{
};
Class C
{
    A a;
    B b(a);   
};


Please let me know the correct way of doing this
C++ is case sensitive. You can't capitalize keywords. class will work, Class will not.
... the compiler is not allowing ...

When the compiler does not like something, it will spit out an error message or warning. You should try to learn to read those messages, because they can help pointing out what the problem is.
Thanks Guys for reply...
I am able to solve the problem..

Explanation:
1) Its "class", just gave above peice of code as example {My typo error :)}
2) Class B was having private destructor and a public expilicit contructur taking argumnet.
3) I tried below and it works fine

Class C
{
C(A& a)
:B(a)
{
}
A a;
B b;
};

Please get back to me if my explanation is not clear info.. :)
you need to do something linke this:
1
2
3
4
5
6
7
8
9
class A
{

};

class B
{
  B(const A& a) // you use const to make sure you don't change anything in a
};

That should work at what you want.

Thank you :) incarporated your review comment...
Topic archived. No new replies allowed.