| aclark17 (16) | |
|
Class a Class b When i use a as a.static member of b i cannot access any of the method of class.a. Within b Unresolved external | |
|
|
|
| codewalker (159) | |
| Post the code if you can that will help us to analyse | |
|
|
|
| vlad from moscow (3112) | |||
Apart from declaring a member static you have to define it outside the class. For example
| |||
|
|
|||
| aclark17 (16) | |
|
How would you call method static void setx(int n){x=n;} | |
|
|
|
| vlad from moscow (3112) | |
|
If it is indeed a static method then you can call it by using two different methods. Let assume that this method belongs to class A and a is an object of class A. Then you can write either A::setx( value ); or a.setx( value ); | |
|
Last edited on
|
|
| Peter87 (3691) | |||
| |||
|
|
|||
| aclark17 (16) | |
|
Would a call to setx within the ctor of A change the value of x A() { setx(2); } | |
|
|
|
| vlad from moscow (3112) | |
| Yes, it will be changed. | |
|
|
|