Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chidambaram

macrumors member
Original poster
Mar 9, 2008
67
0
hi all,

I am working in a carbon c++ application using XCode in MAC machine.

I have a class name MainWindow.

I created a object as

MainWindow *mainwindow = new MainWindow(2);

MainWindow class has the function GetEditFieldData()

When i call that function as

mainwindow.GetEditFieldData()

it shows the error as

request for member 'GetEditFieldData' in 'mainwindow', which is of non-class type 'MainWindow'

how can i solve this problem?

Thanks in advance and urgent plz....
 

m85

macrumors newbie
Apr 8, 2008
8
0
Try mainwindow->GetEditFieldData(). This syntax is required for pointers and is shorthand for (*mainwindow).GetEditFieldData().

Example:
Code:
#include <iostream>
#include <string>

class Person
{
	std::string _name;
	int _age;
	
public:
	Person(const std::string& name, int age) : _name(name), _age(age)
	{
	}
	
	~Person(void)
	{
	}
	
	const std::string& name(void) const
	{
		return _name;
	}
	
	void setName(const std::string& name)
	{
		_name = name;
	}
	
	const int& age(void) const
	{
		return _age;
	}
	
	void setAge(int age)
	{
		_age = age;
	}
};

int main (int argc, char* argv[])
{
	Person jobs("Steve Jobs", 53);
	Person* woz = new Person("Steve Wozniak", 57);
	
	std::cout << "Steve Jobs is " << jobs.age() << " years old.\n";
	std::cout << "Steve Wozniak is " << woz->age() << " years old.\n";
	
	delete woz;
	
    return 0;
}

You can find out more here: http://www.cplusplus.com/doc/tutorial/classes.html
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.