-
November 9th, 2013, 11:37 PM
#1
Access variable inside class from other class
Hello,
I am trying to access a variable from another class through another class but it is not returning its "instance"?
Example:
Class View
Code:
...
V3D_Viewer viewer;
...
Class MainWindow
Code:
...
viewer* myView;
myView = new viewer();
...
Class Test
Code:
...
MainWindow window;
window.myView->setBackgroundColor(WHITE);
...
I am new to c++ references and pointers,
can someone help me out?
thanks
-
November 9th, 2013, 11:42 PM
#2
Re: Access variable inside class from other class
Edit:
Class Test
Code:
...
MainWindow window;
window.myView->viewer
...
-
November 10th, 2013, 02:44 AM
#3
Re: Access variable inside class from other class
Code:
...
// MainWindow.h
class MainWindow
{
...
public:
V3D_Viewer* myView;
...
};
// MainWindow.cpp
MainWindow::MainWindow()
{
...
myView = new V3D_Viewer();
...
}
...
// somewhere in other .cpp
window.myView->setBackgroundColor(WHITE);
Best regards,
Igor
-
November 10th, 2013, 02:49 AM
#4
Re: Access variable inside class from other class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|