Thread: problem solving compiler errors

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    30

    problem solving compiler errors

    Hi!

    I'm in need of assistance for a compiler error, that doesnt like me, and me neither since i dont know how to "eraser" it ;-)

    the structs look like this (its a template i am enhancing for my coide)

    Code:
    typedef struct {
    	int ix;
    	int iy;
    	int ic;
    } t_fingertip;
    
    /** List containing all fingertips of the classified probe*/
    typedef list<t_fingertip> FINGERLIST;
    
    
    /** Struct containing all global parameters changeable in the GUI */
    
    typedef struct {
    	int   ikValue; //Initial Value of K Parameter
    	int   ikMin; //Min Value for K Parameter (should be 6)
    	int   ikMax; //Max Value for K Parameter (should be around 50?)
    	int   irValue; //Value of radius
    	int   irMin; // Min Value of radius
    	int   irMax; // Max Value of radius
    /*	float fValue;
    	float fMin;
    	float fMax;*/
    	BOOL  bToggle;
    	BOOL  bDrawClassification;
    	BOOL  bIntelliClassification;
    	int   iRadio;
    	char  acFilename[PATH_MAX];
    } t_GuiOptions;
    
    /** Struct containing local parameters for processing */
    typedef struct {
    	int iMousePosX;
    	int iMousePosY;
    	int iWidth;
    	int iHeight;
    //	BOOL bThumbExist;
    //	BOOL bForefingerExist;
    //	BOOL bMiddlefingerExist;
    //	BOOL bRingfingerExist;
    //	BOOL bLittlefingerExist;
    	IplImage* ptCvImg;
    	IplImage* ptCvResult;
    	IplImage* ptCvVSpace;
    	t_fingertip ft1;
    	t_fingertip ft2;
    	FINGERLIST flist;
    
    
    
    
    } t_LocalVariables;
    
    /** Struct containing parameters for a single fingertip   */
    
    
    
    
    
    /** Streammanipulation for reading and writing the dbfile properly */
    
    ostream& operator<<(ostream& os,const t_fingertip& ft){
    	os << ft.ix << ';' << ft.iy << ';' << ft.ic << '\n';
    	return os;
    }
    
    
    t_fingertip& operator>>(istream& is, t_fingertip& ft){
    	string line;
    	int first, last;
    	if (!getline(is, line))
    		return ft;
    	first = line.find_first_of(';');
    	last = line.find_last_of(';');
    	ft.ix = atoi(line.substr(0, first).c_str());
    	ft.iy = atoi(line.substr(first + 1, last - (first + 1)).c_str());
    	ft.ic = atoi(line.substr(last + 1, line.size() - (last + 1)).c_str());
    // 	cout << ft.x << endl;
    // 	cout << ft.y << endl;
    // 	cout << ft.c << endl;
    	return ft;
    }
    then i get a compiler error in these lines:

    Code:
    int loadfile(string filen, t_LocalVariables *ptLocalVars){
    
    string file;
    
    ifstream infile( filen.c_str(), ios::in);
    if ( !infile ){
    cout << "File " << filen << " failed to load." << endl;
    cout << "Using empty state." << endl;
    return 0;
    }
    int i = 0;
    
    while (true) {
    	if (!infile)
    		break;
    	infile >> ptLocalVars.ft1;
    	ptLocalVars.flist.push_back(ptLocalVars.ft1);
    	++i;
    
    }
    ptLocalVars.flist.pop_back();
    --i;
    cout << "Loaded " << i << " entries from file " << filen << " ." << endl;
    return 0;
    }
    
    int savefile(string filen, t_LocalVariables *ptLocalVars){
    string file = filen;
    
    
    
    ofstream outfile( filen.c_str(), ios::out);
    if (!outfile){
    	cerr << "File " << filen << " failed to open!" << endl;
    	return 0;
    }
    typedef list<t_fingertip>::const_iterator ftiter;
    for(ftiter i = ptLocalVars.flist.begin();i != ptLocalVars.flist.end();++i)
    	outfile << *i;
    
    return 1;
    }
    It says:

    classification.cc: In function `int loadfile(basic_string<char,string_char_traits<char >,__default_alloc_template<true,0> >, t_LocalVariables *)':
    classification.cc:37: request for member `ft1' in `ptLocalVars', which is of non-aggregate type `t_LocalVariables *'
    classification.cc:38: request for member `ft1' in `ptLocalVars', which is of non-aggregate type `t_LocalVariables *'
    classification.cc:42: request for member `flist' in `ptLocalVars', which is of non-aggregate type `t_LocalVariables *'
    classification.cc: In function `int savefile(basic_string<char,string_char_traits<char >,__default_alloc_template<true,0> >, t_LocalVariables *)':
    classification.cc:59: request for member `flist' in `ptLocalVars', which is of non-aggregate type `t_LocalVariables *'
    classification.cc:59: request for member `flist' in `ptLocalVars', which is of non-aggregate type `t_LocalVariables *'
    make: *** [classification.o] Error 1


    Who can help me out please?

    THanks in advance!

    Jan

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    When using a pointer to a structure, you cannot access its members through '.', but have to use '->', pr dereference the pointer.

    Both of these are valid for a pointer:
    (*ptLocalVars).ft // dereference, then access through .
    and
    ptLocalVars->ft1 // use pointer, and then access through ->
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler problem
    By fredi_G in forum C Programming
    Replies: 7
    Last Post: 07-08-2007, 04:41 PM
  2. ASM beginner gets 24 compiler errors on hello world...
    By Desolation in forum Tech Board
    Replies: 12
    Last Post: 06-16-2007, 10:21 PM
  3. detecting errors with the compiler
    By InvariantLoop in forum C++ Programming
    Replies: 6
    Last Post: 04-22-2004, 09:55 PM
  4. Sign-up Thread: Problem Solving #1
    By ygfperson in forum Contests Board
    Replies: 15
    Last Post: 01-26-2003, 02:55 AM
  5. Dev c++ compiler problem
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 04-17-2002, 08:26 AM