Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » How to access other classes variables?
How to access other classes variables? [message #9630] Tue, 22 May 2007 21:13 Go to previous message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
I have a very basic problem with OOP. I have two classes and i want to access a variable in one class which is defined in the other class.

header.h
class1
{
  String a_string;
};

class2
{
 ..
};


class1.cpp
#include "header.h"

class1::class1()
{
  a_string = "TEST";
}


class2.cpp
#include "header.h"

class2::class2()
{
  PromptOK(a_string);
}


How can i use the value of a_string in class2 which is defined in class1?

It's surely very basic noob stuff, but i didn' get it after reading different tutorials.

Michael
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Constructor with parameter
Next Topic: How to use string array with functions?
Goto Forum:
  


Current Time: Sat Apr 27 01:18:59 CEST 2024

Total time taken to generate the page: 0.94573 seconds