View Full Version : how to get the function in class in c++?

Apr 9, 2008, 01:22 AM
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


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....

Apr 9, 2008, 02:35 AM
Try mainwindow->GetEditFieldData(). This syntax is required for pointers and is shorthand for (*mainwindow).GetEditFieldData().


#include <iostream>
#include <string>

class Person
std::string _name;
int _age;

Person(const std::string& name, int age) : _name(name), _age(age)


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

Apr 9, 2008, 04:31 AM
Thank you

its working