473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

non-aggregate type error assistance needed

Hello,

I'm having a hard time trying to figure why my code will not compile.
When I try to compile the code, I get the non-aggregate type error. Any
ideas on what I'm doing wrong?

---------------------------------------------------------------------
File: main.cpp
---------------------------------------------------------------------
#include "roster.h"

int main( void )
{
Roster myRoster();

for( int i =0; i < 3; i++ ){
myRoster.addItem();
}

myRoster.print();
return 0;
}

-------------------------------------------------------------------------
File Roster.h
-------------------------------------------------------------------------
#ifndef _ROSTER_H_
#define _ROSTER_H_

#include "person.h"
#include "student.h"
#include "faculty.h"
#include "admin.h"
#include <iostream>

using std::boolalpha;

struct Node
{
Person *p;
Node *next;
};

class Roster
{
public:
Roster();
~Roster();
bool addItem( void );
bool isEmpty( void );
void print( void );

private:
int Selection();
void rosterAdd( int );
Node *head;
Node *tail;
};
#endif

Regards,
Alden
Apr 5 '06 #1
3 5404

Alden Pierre wrote:
Hello,

I'm having a hard time trying to figure why my code will not compile.
When I try to compile the code, I get the non-aggregate type error. Any
ideas on what I'm doing wrong?

---------------------------------------------------------------------
File: main.cpp
---------------------------------------------------------------------
#include "roster.h"

int main( void )
{
Roster myRoster();
This line does not do waht you think it does. You are trying to declare
a variable of type Roster, called myRoster and default-construct it.

What you've actually done is declared a function called myRoster that
takes no arguments and returns an object of type Roster. Try

Roster myRoster;

for( int i =0; i < 3; i++ ){
myRoster.addItem();
}

myRoster.print();
return 0;
}


<snip>

Gavin Deane

Apr 5 '06 #2
Gavin Deane wrote:
Alden Pierre wrote:
Hello,

I'm having a hard time trying to figure why my code will not compile.
When I try to compile the code, I get the non-aggregate type error. Any
ideas on what I'm doing wrong?

---------------------------------------------------------------------
File: main.cpp
---------------------------------------------------------------------
#include "roster.h"

int main( void )
{
Roster myRoster();


This line does not do waht you think it does. You are trying to declare
a variable of type Roster, called myRoster and default-construct it.

What you've actually done is declared a function called myRoster that
takes no arguments and returns an object of type Roster. Try

Roster myRoster;
for( int i =0; i < 3; i++ ){
myRoster.addItem();
}

myRoster.print();
return 0;
}


<snip>

Gavin Deane

Thanks for the swift reply it worked. I thought by declaring Roster
myRoster() the default constructor would get called. :-)

Regards,
Alden
Apr 5 '06 #3
Alden Pierre wrote:
Thanks for the swift reply it worked. I thought by declaring Roster
myRoster() the default constructor would get called. :-)


That's ok, you're not the first person to make that mistake, and you
won't be the last!

General rule: If it looks like a function declaration, it probably is.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Apr 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: lothar | last post by:
re: 4.2.1 Regular Expression Syntax http://docs.python.org/lib/re-syntax.html *?, +?, ?? Adding "?" after the qualifier makes it perform the match in non-greedy or minimal fashion; as few...
17
by: cheeser | last post by:
Hello all, Please see the question in the code below... Thanks! Dave #include <iostream>
0
by: obhayes | last post by:
Hi All, Im using classic ASP (3.0) and I have a web farm with 2 webservers (webserver A and webserver B, both windows server 2003). I do not want to store any client specific information on the...
1
by: brad | last post by:
Hi, Im using classic ASP (3.0) and I have a web farm with 2 webservers (webserver A and webserver B, both windows server 2003). I do not want to store any client specific information on the...
5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
11
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.