Re: Non Aggregate Type?

Discussion in 'C++' started by Ryan Vilim, Aug 2, 2003.

  1. Ryan Vilim

    Ryan Vilim Guest

    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=='='));
    >>
    >> if(currentline=='=') {
    >>
    >> 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
    Ryan Vilim, Aug 2, 2003
    #1
    1. Advertising

  2. Ryan Vilim

    Artie Gold Guest

    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=='='));
    >
    > if(currentline=='=') {
    >
    > 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
    Artie Gold, Aug 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Goodsell

    Re: Non Aggregate Type?

    Kevin Goodsell, Aug 2, 2003, in forum: C++
    Replies:
    1
    Views:
    617
    Kevin Goodsell
    Aug 2, 2003
  2. Christian Christmann

    non-aggregate type bool

    Christian Christmann, Mar 25, 2005, in forum: C++
    Replies:
    3
    Views:
    1,745
    Donovan Rebbechi
    Mar 25, 2005
  3. Alden Pierre
    Replies:
    3
    Views:
    342
    Ben Pope
    Apr 5, 2006
  4. Timothee Groleau

    non-aggregate type error?

    Timothee Groleau, Apr 27, 2006, in forum: C++
    Replies:
    2
    Views:
    704
    Timothee Groleau
    Apr 27, 2006
  5. rickman
    Replies:
    5
    Views:
    416
    rickman
    Mar 30, 2013
Loading...

Share This Page