Changing Parents variable in inherited class construktor

Hello, I am new in C++ so I apologize for awfull Code.

How can i change my Parents variable in the inherited Class konstruktor? Is it even possible?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  #include <iostream>

using namespace std;

class Tool {
	public: int strength;
			char type[]; // Variable i want to change in the certain class
	

};

class Scissors : public Tool {
	
	public: Scissors(int strength, char type);
			//static const char *type;
			
	public: bool fight(Tool enemy){
			return true;
	};
};

//const char *Scissors::type = "Scissor";
Scissors::Scissors(int strengthparam){
	strength = strengthparam;
     // tried to change the char type[] here but without success :(


}

int main(void)
{
	// Example main function
	Scissors s1(6);
       cout << s1.type << endl;  // not sure if this is the right way to call the type cause its defined in the Tool class
	return 0;
}
Last edited on
Topic archived. No new replies allowed.