Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2005
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2005 by Ivor Horton; ISBN: 9780764571978
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 13th, 2007, 10:34 PM
Registered User
 
Join Date: May 2007
Location: , CA, .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default CH 9 error code city

Ex9_01
My code matches the book and 571974 file yet here is what I get.

1>------ Build started: Project: Ex9_01, Configuration: Debug Win32 ------
1>Compiling...
1>Ex9_01.cpp
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\candybox.h(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\candybox.h(13) : warning C4183: 'CCandyBox': missing return type; assumed to be a member function returning 'int'
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\candybox.h(14) : error C2523: 'CCandybox::~CCandyBox' : destructor tag mismatch
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\ex9_01.cpp(13) : error C2065: 'CCandyBox' : undeclared identifier
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\ex9_01.cpp(13) : error C2146: syntax error : missing ';' before identifier 'myCandyBox'
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\ex9_01.cpp(13) : error C2065: 'myCandyBox' : undeclared identifier
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\ex9_01.cpp(14) : error C2146: syntax error : missing ';' before identifier 'myMintBox'
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\ex9_01.cpp(14) : error C3861: 'myMintBox': identifier not found
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\ex9_01.cpp(20) : error C2070: ''unknown-type'': illegal sizeof operand
1>c:\aaaaaa\visual studio\ex9_01\ex9_01\ex9_01.cpp(22) : error C2070: ''unknown-type'': illegal sizeof operand
1>Build log was saved at "file://c:\AAAAAA\Visual Studio\Ex9_01\Ex9_01\Debug\BuildLog.htm"
1>Ex9_01 - 9 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Any ideas?


  #2 (permalink)  
Old June 14th, 2007, 02:09 AM
Registered User
 
Join Date: May 2007
Location: , CA, .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could there be a setting in Visual Studio 8 that might be causing this?
Mabe a linker, incude file, or debug setting.
When I was working on sketcher I would get only one or two errors that I could fix and then on the third compile I got 284 errors. The errors don't make any sense to me. Has the language changed sinse I baught this book?
I have a hunch it might have something to do with include files and Microsoft DirectX SDK (February 2007)which I installed prior to installing Visual Studio 8. Maybe VS 8 is looking in the wrong place for include files.

Here is my code try it yourself and see if you get the same errors.

// Header filr box.h in project Ex9_01
#pragma once

class CBox
{
public:
    double m_Length;
    double m_Width;
    double m_Height;

    CBox(double lv = 1.0, double wv = 1.0, double hv = 1.0):
    m_Length(lv), m_Width(wv), m_Height(hv){}
};



// Header file CandyBox.h in project Ex9_01
#pragma once
#include "box.h"
class CCandybox: CBox
{
public:
    char* m_Contents;

    CCandyBox(char* str = "Candy") // Constructor
    {
        m_Contents = new char[ strlen(str) + 1 ];
        strcpy_s(m_Contents, strlen(str) + 1, str);
    }
    ~CCandyBox()
    { delete[] m_Contents; };
};


// Ex9_01.cpp
// Using a derived class
#include <iostream> // For stream I/O
#include <cstring> // For strlen() and strcpy()
#include "CandyBox.h" // For CBox and CCandyBox
using std::cout;
using std::endl;


int main()
{
  CBox myBox(4.0, 3.0, 2.0); // Create CBox object
  CCandyBox myCandyBox;
  CCandyBox myMintBox("Wafer Thin Mints"); // Create CCandyBox object

  cout << endl
       << "myBox occupies " << sizeof myBox // Show how much memory
       << " bytes" << endl // the objects require
       << "myCandyBox occupies " << sizeof myCandyBox
       << " bytes" << endl
       << "myMintBox occupies " << sizeof myMintBox
       << " bytes";

  cout << endl
       << "myBox length is " << myBox.m_Length;

  myBox.m_Length = 10.0;

  // myCandyBox.m_Length = 10.0; // uncomment this for an error

  cout << endl;
  return 0;
}




  #3 (permalink)  
Old July 15th, 2007, 09:29 AM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi shade cat,

It's been a while since you posted this so you might've already solved it by now. So sorry if I'm telling you something you already know.

I think what's causing the problem is just a little typo. In your CandyBox.h file you have the line "class CCandybox: CBox". This should be "class CCandyBox: CBox" - a captial "B" for the 'box' in CandyBox. If you make this tiny correction I think it will compile fine.

Hope this helps.

Dan

  #4 (permalink)  
Old July 20th, 2007, 01:55 PM
Registered User
 
Join Date: May 2007
Location: , CA, .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help. Your the first person to reply to one of my questions. I was beginning to think this site was a ghost town. I can't remember if I solved this one or not. I have been jumping around reading four different programming books and I just ordered no. 5 in attempt to understand this language. I will be coming back to this section to review in 2 or 3 weeks. Your help is much appreciated

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
ch 8 code is not working properly Dev_gh78 C# 1 August 4th, 2006 12:16 AM
User's Exact Location (Country, City, Continent) hunzian78@yahoo.com ASP.NET 1.0 and 1.1 Professional 3 March 8th, 2006 12:49 AM
Ch. 15 Add'l Code? gekkster99999 BOOK: Beginning ASP 3.0 0 February 1st, 2004 10:55 PM



All times are GMT -4. The time now is 08:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.