chronie
Sep27-10, 10:12 PM
Hi,
I am new to programming, but I think this is a simple error. For my programming code Im trying to pass a variable from a certain class to another class. The code is similar to below.
Class 1
#include "class2"
Class2 class
var1=1
var2=2
class.acceptingvariablesfrom1(var1 var2)
Class 2
class.acceptingvariablesfrom1(var1 var2)
cout << var1 << endl;
That is what my basic code looks like. I send my var1 and var2 to my acceptingvariablesclass however, how do I have them displayed. When I do my cout statement I get garbage. Am I doing something wrong? Class1 and Class2 are different .cpp files. In Class2 do I have to define var1 and var2 again even though they were defined in class1?
I think this is a basic question but I just dont understand why I am getting garbage values?
I am new to programming, but I think this is a simple error. For my programming code Im trying to pass a variable from a certain class to another class. The code is similar to below.
Class 1
#include "class2"
Class2 class
var1=1
var2=2
class.acceptingvariablesfrom1(var1 var2)
Class 2
class.acceptingvariablesfrom1(var1 var2)
cout << var1 << endl;
That is what my basic code looks like. I send my var1 and var2 to my acceptingvariablesclass however, how do I have them displayed. When I do my cout statement I get garbage. Am I doing something wrong? Class1 and Class2 are different .cpp files. In Class2 do I have to define var1 and var2 again even though they were defined in class1?
I think this is a basic question but I just dont understand why I am getting garbage values?