I get 27 errors when I try to compile, none of which make sense to me, since the code looks good. I have my header file included, and all of my function definitions are in the class contained in the header. You can see an assignment sheet here .
I am not looking for someone to do it for me, but rather someone to point out the error causing code...This program is supposed to do what is described in the sheet linked above. And now for the code...
Logbook.cpp (The only source I am supposed to edit):
logbook.h: - //--------------------------------------------------------------------
-
//
-
// Laboratory 1 logbook.h
-
//
-
// Class declaration for the Logbook ADT
-
//
-
//--------------------------------------------------------------------
-
-
class Logbook
-
{
-
public:
-
-
// Constructor
-
Logbook ( int month, int year ); // Create a logbook
-
-
// Logbook marking operations
-
void putEntry ( int day, int value ); // Store entry for day
-
int getEntry ( int day ) const; // Return entry for day
-
-
// General operations
-
int month () const; // Return the month
-
int year () const; // Return the year
-
int daysInMonth () const; // Number of days in month
-
-
// In-lab operations
-
void displayCalendar () const; // Display as calendar
-
Logbook (); // Default constructor
-
void putEntry ( int value ); // Store entry for today
-
int operator [] ( int day ) const; // Return entry for day
-
void operator += ( const Logbook &rightLogbook );
-
// Combine logbooks
-
private:
-
-
// Facilitator (helper) function
-
int leapYear () const; // Leap year?
-
-
// In-lab facilitator function
-
int dayOfWeek ( int day ) const; // Return day of the week
-
-
// Data members
-
int logMonth, // Month covered by logbook
-
logYear,
-
entry [32]; // Logbook entries
-
};
8 3307
the errors (I fixed the switch error...but the others I still get): - ------ Build started: Project: lab1, Configuration: Debug Win32 ------
-
Compiling...
-
Logbook.cpp
-
f:\c projects\112\lab1\logbook.cpp(9) : error C2143: syntax error : missing ';' before '{'
-
f:\c projects\112\lab1\logbook.cpp(15) : error C2065: 'logMonth' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(16) : error C2065: 'logYear' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(18) : error C3861: 'daysInMonth': identifier not found
-
f:\c projects\112\lab1\logbook.cpp(21) : error C2065: 'entry' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(25) : error C2144: syntax error : 'int' should be preceded by ')'
-
f:\c projects\112\lab1\logbook.cpp(25) : error C2059: syntax error : ')'
-
f:\c projects\112\lab1\logbook.cpp(26) : error C2143: syntax error : missing ';' before '{'
-
f:\c projects\112\lab1\logbook.cpp(27) : error C2065: 'month' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(28) : error C2065: 'year' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(30) : error C2065: 'NumberOfDays' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(36) : error C2601: 'Logbook::putEntry' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(43) : error C2601: 'Logbook::getEntry' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(51) : error C2601: 'Logbook::month' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(56) : error C2601: 'Logbook::year' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(61) : error C2601: 'Logbook::daysInMonth' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(92) : error C2601: 'Logbook::displayCalendar' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(126) : error C2144: syntax error : 'int' should be preceded by ';'
-
f:\c projects\112\lab1\logbook.cpp(126) : error C2761: 'putEntry' : member function redeclaration not allowed
-
f:\c projects\112\lab1\logbook.cpp(127) : error C2601: 'Logbook::operator []' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(132) : error C2601: 'operator +=' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(140) : error C2601: 'Logbook::leapYear' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(148) : error C2601: 'Logbook::dayOfWeek' : local function definitions are illegal
-
f:\c projects\112\lab1\logbook.cpp(6): this line contains a '{' which has not yet been matched
-
f:\c projects\112\lab1\logbook.cpp(75) : error C2196: case value '6' already used
-
f:\c projects\112\lab1\logbook.cpp(96) : error C2065: 'cout' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(96) : error C2065: 'endl' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(132) : error C2805: binary 'operator +=' has too few parameters
-
f:\c projects\112\lab1\logbook.cpp(158) : error C2660: 'Logbook::daysInMonth' : function does not take 1 arguments
-
Build log was saved at "file://f:\c projects\112\LAB1\lab1\Debug\BuildLog.htm"
-
lab1 - 28 error(s), 0 warning(s)
-
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Down to just the 7 errors: - --------------------Configuration: Logbook - Win32 Debug--------------------
-
Compiling...
-
Logbook.cpp
-
Logbook.cpp(33) : error C2065: 'NumberOfDays' : undeclared identifier
-
Logbook.cpp(139) : error C2805: binary 'operator +=' has too few parameters
-
Logbook.cpp(141) : error C2065: 'entry' : undeclared identifier
-
Logbook.cpp(141) : error C2109: subscript requires array or pointer type
-
Logbook.cpp(141) : error C2248: 'entry' : cannot access private member declared in class 'Logbook'
-
logbook.h(43) : see declaration of 'entry'
-
Logbook.cpp(141) : error C2106: '+=' : left operand must be l-value
-
Logbook.cpp(165) : error C2660: 'daysInMonth' : function does not take 1 parameters
-
Error executing cl.exe.
-
-
Testall.exe - 7 error(s), 0 warning(s)
I love you (in a totally hetero way). GOD BLESS! THANKS!
I hope I can repay the favor sometime.
Of course, I don't know why I am getting those errors. I have seen an example, and my code looks allright.
I still get these: - ------ Build started: Project: lab1, Configuration: Debug Win32 ------
-
Compiling...
-
Logbook.cpp
-
f:\c projects\112\lab1\logbook.cpp(139) : error C2805: binary 'operator +=' has too few parameters
-
f:\c projects\112\lab1\logbook.cpp(141) : error C3861: 'daysInMonth': identifier not found
-
f:\c projects\112\lab1\logbook.cpp(143) : error C2065: 'logMonth' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(143) : error C2248: 'Logbook::logMonth' : cannot access private member declared in class 'Logbook'
-
f:\c projects\112\lab1\logbook.h(41) : see declaration of 'Logbook::logMonth'
-
f:\c projects\112\lab1\logbook.h(10) : see declaration of 'Logbook'
-
f:\c projects\112\lab1\logbook.cpp(144) : warning C4390: ';' : empty controlled statement found; is this the intent?
-
f:\c projects\112\lab1\logbook.cpp(150) : error C2065: 'entry' : undeclared identifier
-
Build log was saved at "file://f:\c projects\112\LAB1\lab1\Debug\BuildLog.htm"
-
lab1 - 5 error(s), 1 warning(s)
-
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Code: - ------ Build started: Project: lab1, Configuration: Debug Win32 ------
-
Compiling...
-
Logbook.cpp
-
f:\c projects\112\lab1\logbook.cpp(139) : error C2805: binary 'operator +=' has too few parameters
-
f:\c projects\112\lab1\logbook.cpp(141) : error C3861: 'daysInMonth': identifier not found
-
f:\c projects\112\lab1\logbook.cpp(143) : error C2065: 'logMonth' : undeclared identifier
-
f:\c projects\112\lab1\logbook.cpp(143) : error C2248: 'Logbook::logMonth' : cannot access private member declared in class 'Logbook'
-
f:\c projects\112\lab1\logbook.h(41) : see declaration of 'Logbook::logMonth'
-
f:\c projects\112\lab1\logbook.h(10) : see declaration of 'Logbook'
-
f:\c projects\112\lab1\logbook.cpp(144) : warning C4390: ';' : empty controlled statement found; is this the intent?
-
f:\c projects\112\lab1\logbook.cpp(150) : error C2065: 'entry' : undeclared identifier
-
Build log was saved at "file://f:\c projects\112\LAB1\lab1\Debug\BuildLog.htm"
-
lab1 - 5 error(s), 1 warning(s)
-
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Just quickly:
Operator += is a binary operator; it takes two arguments, a left and a right element.
Operator += is not in the Logbook namespace, therefor you will need to reference daysInMonth() as Logbook::daysInMonth(). Same goes for logmonth.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alex Endl |
last post by:
ok now that i know the random function, i made this guessing game. I get an
error though, and Im new so im not to good at figuring out what its talking
about.
import random
a =...
|
by: bill wilson |
last post by:
Hi folks,
I am new to php+mysql, can anyone help on this query?
If we have a table
id name
1 allen
2 bill
3 mark
15 david
|
by: KK |
last post by:
Design Pattern help for this scenerio?.
I need some expert advice on possible ways
to design the classes for following scenerio.
Subject domain has 3 types of identities.
Lets say <IDType1>,...
|
by: MDOPro |
last post by:
A pal needs help on this site
greetings fellow newsgroupers. I recently found a site called Microsoft
Forums. In a very short time I became very known to the site and its an
excellent tool....
|
by: TN Bella |
last post by:
Hi,
I am trying to get my compare validator to fire properly...Since I have
panels the validator wouldn't work properly, the app would fire right
but would insert the data regardless and the...
|
by: Merdelus |
last post by:
I'm a new visual basic learner, I need some help with this
program below:
create an application that either sums or averagethe rows
or columns of a two dimensional array depending on user...
|
by: MK |
last post by:
Hello,
I am new to XML and PERL and I have a few questions the answers to
which I need to complete a project. All your time and effort would be
highly appreciated. I have to make a small HTML page...
|
by: shantanuaggarwal |
last post by:
Hi,,
I have one following question that whether attributes can help me in resolving this problem:
I have one base class called Employee
and I have 3 classes which inherit it:
EmployeeA...
|
by: flavourofbru |
last post by:
Hi,
I am stuck at a major part of the code in VC++.
My algorithm is as follows:
f_name = load(filename);
//this also loads a text file. The text files contains numbers sepearted by tab....
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |