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 Chriss Miller 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
Joined
Jul 23, 2001
Messages
7
Location
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

--
 
This worked. Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top