non-aggregate type problem

Andre Kirchner supercroc1974@yahoo.com
Tue Jul 20 22:14:00 GMT 2004


Hi,

could someone please explain me the meaning of
"request for member `sendMessage' in
'this->Sender::theConnector', which is of
non-aggregate type `Connector*'"?

In the following code I created an object Connector
called theConnector. Then when I created an object
Sender called theSender, I passed a pointer to
theConnector as a parameter.
I thought it would allow the to use theConnector
object inside theSender, but for some reason it is not
working.

Thanks,

Andre

-------------------------------------------------
main.cpp:

#ifndef MAIN
#	define MAIN
#	include "main.h"
#endif

int main( int argc, char *argv[] )
{
	char theMessage[ 256 ];
	Connector theConnector;
	Sender theSender( &theConnector );

	bzero( theMessage, 256 );
    	theConnector.establishConnection( "65.54.252.99",
25 );
	
	theConnector.receiveMessage( theMessage, 255 );
	printf( "%s\n", theMessage );

	theSender.sendHELO();
	theConnector.receiveMessage( theMessage, 255 );
	printf( "%s\n", theMessage );
    	
    	theConnector.closeConnection();

	return ( EXIT_SUCESS );
}

____________________________________________
Sender.h:

#ifndef STRING
#	define STRING
#	include <string.h>
#endif

#ifndef CONNECTOR
#	define CONNECTOR
#	include "Connector.h"
#endif

class Sender
{
  public:
    Sender(){};
    Sender( Connector * newConnector );
    ~Sender(){};
    int setOrigin( const char * newOrigin );
    int setDestiny( const char * newDestiny );
    int setData( const char * newData );
    int sendHELO();
    int sendMAILFROM();
    int sendRCPT();
    int sendDATA();
    
  private:
    char theOrigin[ 256 ], theDestiny[ 256 ], theData[
256 ];
    Connector * theConnector;
};
_____________________________________________
Sender.cpp:

#ifndef SENDER
#	define SENDER
#	include "Sender.h"
#endif

int Sender::sendHELO()
{
	theConnector.sendMessage( "HELO test" );
}

_________________________________________________
Connector.h:

class Connector
{
  public:
    Connector(){};
    ~Connector(){};
    int establishConnection( const char *
theMailServerName, int thePortNumber );
    int sendMessage( const char * theMessage );
    int receiveMessage( char * theMessage, int
theMessageLength );
    int closeConnection();

  private:
    int sockfd;
};


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Gcc-help mailing list