Nested Union Structure and scope resolution operator
From: Camford (Cam_at_mac.ca.ku)
Date: 04/15/04
- Next message: Howard: "Re: const structure & member pointers"
- Previous message: Thomas Stegen: "Re: const structure & member pointers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 15 Apr 2004 19:34:46 +0100
I have just started on C++. Today I tried to compile the following source
and I got some error messages.
#include <iostream>
#include <string>
using namespace std; //introduces namespace std
union myunion2
{
struct Point3d
{
float x;
float y;
float z;
}
pt;
struct Rectangle
{
int l;
int t;
int r;
int b;
}
rect;
};
void main( )
{
myunion2 mu;
mu.Point3d::x = 1.0f; //this line gives the error. Illegal use of
non-static member
//rest of the code
cout << "This is a test" ;
;
}
I got the code from a book called "Using C++" by Rob McGregor, published
1998. I tried to compile the source using both C++ Builder and Metrowerks
CodeWorrier with no luck. Any help on the proper usage of nested structure
and scope resolution operator will be appreciated.
-- Camford --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.657 / Virus Database: 422 - Release Date: 13/04/2004
- Next message: Howard: "Re: const structure & member pointers"
- Previous message: Thomas Stegen: "Re: const structure & member pointers"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|