Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: Non Aggregate Type? (http://www.velocityreviews.com/forums/t276315-re-non-aggregate-type.html)

Ryan Vilim 08-02-2003 12:09 AM

Re: Non Aggregate Type?
 
Artie Gold wrote:

> Ryan Vilim wrote:
>> I am getting this really odd errer in my C++ program,
>>
>> request for member `readconfig' in `popmem()', which is of non-aggregate
>> type `init ()()'
>>
>>
>> This occurs when I try to call a member function from my class
>>
>> The source (posted below) io only one ciass that opens a config file and
>> reads from it. It is split up into 3 files definitions.h which is where
>> my class definition aos well as a constant for the path and a singly
>> linked list which I will use later. Next is cls_init.h which contains the
>> init classes member functions. Then there is main.cpp which does the
>> calling
>>
>> definitions.h is included in cls_init which is then included in main.cpp.
>>
>> BTW I am using gcc 3.2.3 on Gentoo Linux.
>>
>> Anyways here is my code
>>
>>
>> Definitions.h
>> ************************************************** *********************
>>
>> typedef struct series {
>>
>> char name[40];
>> bool notify;
>> bool autodownload;
>> char path[100];
>> series *next;
>> };
>>
>> class init {
>>
>> private:
>> void interpretline(char currentline[100]);
>> void getline(void);
>>
>>
>> public:
>>
>> void readconfig(void);
>>
>> };
>>
>> #define CONFIGPATH "/etc/watchman/watchman.conf"
>>
>> ************************************************** *********************
>>
>> cls_init.h
>>
>> ************************************************** *********************
>>
>> #include "definitions.h"
>> #include <stdio.h>
>> #include <iostream.h>
>>
>>
>> void init::readconfig(void) {
>>
>> this->getline();
>>
>> }
>>
>> void init::getline() {
>>
>> char c, currentline[100];
>> int i;
>> FILE * pFile;
>> pFile=fopen (CONFIGPATH,"r");
>>
>> if (pFile==NULL) {
>>
>> perror ("Error opening file");
>> }
>> else
>> {
>> do{
>>
>> c=fgetc (pFile);
>> i=c;
>>
>> if(i==13) {
>>
>> fgets (currentline, ftell (pFile) ,
>> pFile);
>> }
>>
>> }while((c!=EOF)||(i!=13));
>> }
>>
>> this->interpretline(currentline);
>> }
>>
>>
>> void init::interpretline(char currentline[100]) {
>>
>> int i,a;
>> char varname[15];
>> char command[100];
>> if(currentline[0]!='<'){
>>
>> do {
>>
>> i++;
>>
>> }while ((i!=strlen(currentline))||(currentline[i]=='='));
>>
>> if(currentline[i]=='=') {
>>
>> memcpy(command,currentline,i);
>>
>> for(a=i; a< strlen(currentline) - i; a++) {
>>
>> command[a]=currentline[a-i];
>>
>> }
>>
>> }
>> }
>>
>> cout<<command<<endl;
>> cout<<varname<<endl;
>>
>> }
>>
>> ************************************************** *********************
>>
>> main.cpp
>>
>> ************************************************** *********************
>>
>> #include "cls_init.h"
>>
>> int main(int argc, char *argv[])
>> {
>>
>> init popmem ();

>
> This declares a function called `popmem' that takes no arguments and
> returns an instance of class `init'.
>
> You want:
>
> init popmem;
>
>>
>> popmem.readconfig();
>>
>> return EXIT_SUCCESS;
>> }

>
> HTH,
> --ag
>
>


gah! I should have noticed that. Thanks for the speedy reply

Ryan Vilim

Artie Gold 08-02-2003 03:51 AM

Re: Non Aggregate Type?
 
Ryan Vilim wrote:
> I am getting this really odd errer in my C++ program,
>
> request for member `readconfig' in `popmem()', which is of non-aggregate
> type `init ()()'
>
>
> This occurs when I try to call a member function from my class
>
> The source (posted below) io only one ciass that opens a config file and
> reads from it. It is split up into 3 files definitions.h which is where my
> class definition aos well as a constant for the path and a singly linked
> list which I will use later. Next is cls_init.h which contains the init
> classes member functions. Then there is main.cpp which does the calling
>
> definitions.h is included in cls_init which is then included in main.cpp.
>
> BTW I am using gcc 3.2.3 on Gentoo Linux.
>
> Anyways here is my code
>
>
> Definitions.h
> ************************************************** *********************
>
> typedef struct series {
>
> char name[40];
> bool notify;
> bool autodownload;
> char path[100];
> series *next;
> };
>
> class init {
>
> private:
> void interpretline(char currentline[100]);
> void getline(void);
>
>
> public:
>
> void readconfig(void);
>
> };
>
> #define CONFIGPATH "/etc/watchman/watchman.conf"
>
> ************************************************** *********************
>
> cls_init.h
>
> ************************************************** *********************
>
> #include "definitions.h"
> #include <stdio.h>
> #include <iostream.h>
>
>
> void init::readconfig(void) {
>
> this->getline();
>
> }
>
> void init::getline() {
>
> char c, currentline[100];
> int i;
> FILE * pFile;
> pFile=fopen (CONFIGPATH,"r");
>
> if (pFile==NULL) {
>
> perror ("Error opening file");
> }
> else
> {
> do{
>
> c=fgetc (pFile);
> i=c;
>
> if(i==13) {
>
> fgets (currentline, ftell (pFile) , pFile);
> }
>
> }while((c!=EOF)||(i!=13));
> }
>
> this->interpretline(currentline);
> }
>
>
> void init::interpretline(char currentline[100]) {
>
> int i,a;
> char varname[15];
> char command[100];
> if(currentline[0]!='<'){
>
> do {
>
> i++;
>
> }while ((i!=strlen(currentline))||(currentline[i]=='='));
>
> if(currentline[i]=='=') {
>
> memcpy(command,currentline,i);
>
> for(a=i; a< strlen(currentline) - i; a++) {
>
> command[a]=currentline[a-i];
>
> }
>
> }
> }
>
> cout<<command<<endl;
> cout<<varname<<endl;
>
> }
>
> ************************************************** *********************
>
> main.cpp
>
> ************************************************** *********************
>
> #include "cls_init.h"
>
> int main(int argc, char *argv[])
> {
>
> init popmem ();


This declares a function called `popmem' that takes no arguments and
returns an instance of class `init'.

You want:

init popmem;

>
> popmem.readconfig();
>
> return EXIT_SUCCESS;
> }


HTH,
--ag


--
Artie Gold -- Austin, Texas



All times are GMT. The time now is 08:29 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.