how to get the function in class in c++?

Discussion in 'Mac Programming' started by chidambaram, Apr 8, 2008.

  1. chidambaram macrumors member

    Mar 9, 2008
    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....
  2. m85 macrumors newbie

    Apr 8, 2008
    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:
  3. chidambaram thread starter macrumors member

    Mar 9, 2008

Share This Page