public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* non-aggregate type problem
@ 2004-07-20 22:14 Andre Kirchner
  2004-07-23  9:31 ` Stuart Brooks
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Kirchner @ 2004-07-20 22:14 UTC (permalink / raw)
  To: gcc-help

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 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: non-aggregate type problem
  2004-07-20 22:14 non-aggregate type problem Andre Kirchner
@ 2004-07-23  9:31 ` Stuart Brooks
  0 siblings, 0 replies; 2+ messages in thread
From: Stuart Brooks @ 2004-07-23  9:31 UTC (permalink / raw)
  To: Andre Kirchner, gcc-help

I think your SendHELO method should look like this... (note the "->")

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

Regards
 Stuart


----- Original Message ----- 
From: "Andre Kirchner" <supercroc1974@yahoo.com>
To: <gcc-help@gcc.gnu.org>
Sent: Wednesday, July 21, 2004 12:14 AM
Subject: non-aggregate type problem


> 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 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-07-23  9:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-20 22:14 non-aggregate type problem Andre Kirchner
2004-07-23  9:31 ` Stuart Brooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).