Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Struct from within a Class

Status
Not open for further replies.

mcbrune

Programmer
Jul 23, 2001
7
US
I have the following code:

class myClass
{

struct Points
{
int x;
int y;
};

}

In a member function I have:

myClass::memberFunction()
{
int startRow;
int startColumn;

myClass::points.x = startRow;
myClass::points.y = startColumn;
}

When I try to compile, I receive:

In method `struct myClass::points myClass::Maze(char *)':
syntax error before `.'
syntax error before `.'
syntax error before `;'

using g++ version 3.1. Any ideas of what I am doing wrong?

Thanks in advance,
Corey
 
You need a member within the class which has the type Points

Code:
class myClass
{

struct Points
        {
                int x;
                int y;
        };


        Points here;
};

Then you have here.x and here.y

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top