What causes

a string not being recognized when using multiple headers and cpp file

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 1088 Views - Last Post: 12 November 2009 - 06:32 AM Rate Topic: -----

#1 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

What causes

Posted 12 November 2009 - 02:19 AM

For some reason I am getting mad undeclared identifiers and this happened about 2 weeks ago to me its like my compiler is not understanding what a string is. I have the #include <string> code in my stdafx.h but it just seems like its not catching onto it. I say this because multiple strings are not getting recognized and they are coming up as undeclared identifiers or syntax errors that just don't make any logical sense. I'll post up my code if need be but I'm not fully done yet.

Is This A Good Question/Topic? 0
  • +

Replies To: What causes

#2 hackterr  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 293
  • Joined: 13-August 09

Re: What causes

Posted 12 November 2009 - 02:22 AM

post your code
reminder: c++ is a strongly typed language
Was This Post Helpful? 0
  • +
  • -

#3 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

Re: What causes

Posted 12 November 2009 - 02:37 AM

ok here is what I have so far I'm sur a lot of you D.I.C heads have see something similar for I am a student at Devry working on the timeZone assignment, yet very frustrated for I was supposed to be in the Keys in 6 hrs and have to now wait till Friday. here is the code I have so far

my stdafx.h
#pragma once

#ifndef _WIN32_WINNT			// Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600	 // Change this to the appropriate value to target other versions of Windows.
#endif

#include <iostream>
#include <stdio.h>
#include <tchar.h>
#include "extTime.h"
#include "time.h"
#include <string>
using namespace std;



my time.h
#pragma once

#include "stdafx.h"

class time
{
public:
	time();//the default constructor
	time(int hrs, int min, char zone);// constructor with parameters
	~time(void);//deconstructor
	void setHour();//sets the hour
	void setMinute();//sets the minute
	int getHour();//gets the hour and returns a value
	int getMinute();//gets the minute and returns a value	
	void incrementHrs();//increments the hour
	void incrementMin();//incrememts the minute
	void printTime();//prints the hour and the minute

protected:
	int hour;//declares the hour
	int minute;//declares the minute
	char zone;//declares the time zone
};



my extTime.h
#pragma once

#include "stdafx.h"

class extTime : public time
{
public:
	extTime();//default constructor
	extTime(int hr, int min, string tZone);//constructor with parameters
	~extTime(void);//destructor
	void timeZone();
	void printTime();//redefining the print member function of the base class
private:
	string tZone;//a new data member specific to the derived class
				  //this assumes time zone is denoted by one character
};



my time.cpp
#include "stdafx.h"

time::time()//implementation of the default constructor
{
	hour = 0;
	minute = 0;
}
time::time(int hrs, int mins, char tZone)//implementation of the constructor with parameters
{
	hour = hrs;
	minute = mins;
}
time::~time(void)
{
}
void time::setHour(int hrs)
{
	hour = hrs;
}
void time::setMinute(int mins)
{
	minute = mins;
}
int time::getHour()
{
	return hour;	
}
int time::getMinute()
{
	return minute;
}
void time::printTime() const
{
	//note from the if statements that consideration
	//is taken whether the hours and minutes are 1 or 2 digits
	if (hour < 10)
		cout << "0";
	cout << hour << ":";
	hour = 0;
	if (minute < 10)
		cout << "0";
	cout << minute << ":";
}
void time::incrementHrs()
{
	hour++;
		if (hour > 23)
			hour = 0;
}
void time::incrementMin()
{
	minute++;
	if (minute > 59)
		minute = 0;
}



my extTime.h
#include "stdafx.h"

extTime::extTime(void)
{
	if (tZone == "PST")
		cout << "The time is " << (getHour()-3) << ":" << getMinute() << endl;
	if (tZone == "MST")
		cout << "The time is " << (getHour()-2) << ":" << getMinute() << endl;
	if (tZone == "CST")
		cout << "The time is " << (getHour()-1) << ":" << getMinute() << endl;
	if (tZone == "EST")
		cout << "The time is " << getHour() << ":" << getMinute() << endl;
}
extTime::extTime(int hr, int min, string tZone)
{
	hour = hrs;
	minute = mins;
	timeZone = tZone;
}
extTime::~extTime(void)
{
}
void extTime::printTime() const
{
	time::printTime();//which will invoke the original printing function from the base class
	cout << ";Time Zone = " << timeZone;
}



I've erased my main for now for I first need to get these classes working correctly. The errors I'm getting is undeclared identifier string, tZone undeclared identifier, syntax errors before tZone (which makes no sense and is leaving me to believe its not noticing my # include <string>), base class unidentified (not sure why?), functions that are identifuers not being identified such as the get or my getters you could say, mthen misssing type specifiers int assumed (once again I believe most of these errors is due to sting not being recognized)

Any help is appreciated at this point, that way I can work on how I want my main to work. Also please do not have me search for previously disscussions on this for I already have and found this assignment but by having it done differently using flushes, and ushorts which I have not learned yet. Thanks in advance for all your help, patiently waiting everyones response.
Was This Post Helpful? 0
  • +
  • -

#4 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

Re: What causes

Posted 12 November 2009 - 02:47 AM

I believe this is what my pseudocode should be for the main
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{//starts main
//call set time
	//create a time object
	//call time for object
	//set time for object
	//increment time and display new time

	//create a ext time object
	//call time for new object
	//set time for object
	//increment the time for the object
	//show a time zone change
system("pause")//put in a system puase
	return 0;//returns 0 errors
}//ends main




please correct me if I'm wrong
Was This Post Helpful? 0
  • +
  • -

#5 hackterr  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 293
  • Joined: 13-August 09

Re: What causes

Posted 12 November 2009 - 03:03 AM

the Errors you are getting?
Was This Post Helpful? 0
  • +
  • -

#6 Bench  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 857
  • View blog
  • Posts: 2,341
  • Joined: 20-August 07

Re: What causes

Posted 12 November 2009 - 03:14 AM

Where is your declaration for timeZone? its referred to here, but I don't see any class variable with that name
extTime::extTime(int hr, int min, string tZone)
{
    hour = hrs;
    minute = mins;
    timeZone = tZone;
} 

Was This Post Helpful? 0
  • +
  • -

#7 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

Re: What causes

Posted 12 November 2009 - 03:28 AM

sorry that should be under my protected instead of zone be timeZone


View Posthackterr, on 12 Nov, 2009 - 02:03 AM, said:

the Errors you are getting?



tooooooooo mannnyyyyy blah;(

Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 9 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 29 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 30 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 33 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 34 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 38 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 39 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 42 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 43 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 50 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 51 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 54 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 55 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 12 error C3861: 'getMinute': identifier not found c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 6
Error 15 error C3861: 'getMinute': identifier not found c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 8
Error 18 error C3861: 'getMinute': identifier not found c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 10
Error 21 error C3861: 'getMinute': identifier not found c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 12
Error 11 error C3861: 'getHour': identifier not found c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 6
Error 14 error C3861: 'getHour': identifier not found c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 8
Error 17 error C3861: 'getHour': identifier not found c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 10
Error 20 error C3861: 'getHour': identifier not found c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 12
Error 45 error C2511: 'void time::setMinute(int)' : overloaded member function not found in 'time' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\time.cpp 21
Error 44 error C2511: 'void time::setHour(int)' : overloaded member function not found in 'time' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\time.cpp 17
Error 46 error C2511: 'void time::printTime(void) const' : overloaded member function not found in 'time' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\time.cpp 33
Error 22 error C2511: 'extTime::extTime(int,int,std::string)' : overloaded member function not found in 'extTime' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 15
Error 1 error C2504: 'time' : base class undefined c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 6
Error 26 error C2504: 'time' : base class undefined c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 6
Error 35 error C2504: 'time' : base class undefined c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 6
Error 47 error C2504: 'time' : base class undefined c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 6
Error 23 error C2470: 'extTime::getTimeZone' : looks like a function definition, but there is no parameter list; skipping apparent body c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 24
Error 24 error C2352: 'time::printTime' : illegal call of non-static member function c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 31
Error 7 error C2146: syntax error : missing ';' before identifier 'tZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 32 error C2146: syntax error : missing ';' before identifier 'tZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 41 error C2146: syntax error : missing ';' before identifier 'tZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 53 error C2146: syntax error : missing ';' before identifier 'tZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 14
Error 3 error C2146: syntax error : missing ';' before identifier 'getTimeZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 28 error C2146: syntax error : missing ';' before identifier 'getTimeZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 37 error C2146: syntax error : missing ';' before identifier 'getTimeZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 49 error C2146: syntax error : missing ';' before identifier 'getTimeZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 11
Error 56 error C2143: syntax error : missing ';' before 'return' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii.cpp 23
Error 10 error C2065: 'tZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 5
Error 13 error C2065: 'tZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 7
Error 16 error C2065: 'tZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 9
Error 19 error C2065: 'tZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 11
Error 25 error C2065: 'timeZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 32
Error 2 error C2061: syntax error : identifier 'string' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 9
Error 27 error C2061: syntax error : identifier 'string' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 9
Error 36 error C2061: syntax error : identifier 'string' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 9
Error 48 error C2061: syntax error : identifier 'string' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 9
Was This Post Helpful? 0
  • +
  • -

#8 hackterr  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 293
  • Joined: 13-August 09

Re: What causes

Posted 12 November 2009 - 03:33 AM

try including header files separately
not in stdafx.h
extTime::extTime(int hr, int min, string tZone)
{
	hour = hrs;
	minute = mins;
	timeZone = tZone;
}


should be
extTime::extTime(int hr, int min, string tZone)
{
	hour = hr;
	minute = min;
	timeZone = tZone; // what are you doing here? timeZone is a function you are assigning some string to it.
}


you have declared the function
void timeZone();


but you have not defined it anywhere

Lots more errors like that
one more thing
when you define a function make sure you do it after its class definition
thus the order in which you have added your headers may not be right

Correct as many as you can then re post the code

This post has been edited by hackterr: 12 November 2009 - 03:55 AM

Was This Post Helpful? 0
  • +
  • -

#9 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

Re: What causes

Posted 12 November 2009 - 03:40 AM

I told you and thats what I said

too me its as if the string is not being recognized and I have no answer why, grrrr


View Posthackterr, on 12 Nov, 2009 - 02:33 AM, said:

try including header files separately
not in stdafx.h



have to include them seperately for thats how they are teaching us, but I just knocked it down some now its only 38 errors

here are the new errors I added #include "time.h" to my extTime.h file

Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 18 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 21 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 22 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 25 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 26 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 29 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 30 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 36 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 37 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 40 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 41 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 32 error C2511: 'void time::setMinute(int)' : overloaded member function not found in 'time' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\time.cpp 21
Error 31 error C2511: 'void time::setHour(int)' : overloaded member function not found in 'time' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\time.cpp 17
Error 33 error C2511: 'void time::printTime(void) const' : overloaded member function not found in 'time' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\time.cpp 33
Error 13 error C2511: 'extTime::extTime(int,int,std::string)' : overloaded member function not found in 'extTime' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 15
Error 14 error C2470: 'extTime::getTimeZone' : looks like a function definition, but there is no parameter list; skipping apparent body c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 24
Error 6 error C2146: syntax error : missing ';' before identifier 'tZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 20 error C2146: syntax error : missing ';' before identifier 'tZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 28 error C2146: syntax error : missing ';' before identifier 'tZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 39 error C2146: syntax error : missing ';' before identifier 'tZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 15
Error 2 error C2146: syntax error : missing ';' before identifier 'getTimeZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 16 error C2146: syntax error : missing ';' before identifier 'getTimeZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 24 error C2146: syntax error : missing ';' before identifier 'getTimeZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 35 error C2146: syntax error : missing ';' before identifier 'getTimeZone' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 12
Error 42 error C2143: syntax error : missing ';' before 'return' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii.cpp 23
Error 9 error C2065: 'tZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 5
Error 10 error C2065: 'tZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 7
Error 11 error C2065: 'tZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 9
Error 12 error C2065: 'tZone' : undeclared identifier c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 11
Error 1 error C2061: syntax error : identifier 'string' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 10
Error 15 error C2061: syntax error : identifier 'string' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 10
Error 23 error C2061: syntax error : identifier 'string' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 10
Error 34 error C2061: syntax error : identifier 'string' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.h 10
Was This Post Helpful? 0
  • +
  • -

#10 Bench  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 857
  • View blog
  • Posts: 2,341
  • Joined: 20-August 07

Re: What causes

Posted 12 November 2009 - 03:46 AM

It doesn't help anyone if the code you post doesn't reflect the errors you're seeing - we can't help you if the code you're looking at is different to the code you've posted.

Get rid of stdafx.h and #include headers in the files where they are needed; putting all of your #includes in a single file is nearly always a bad idea, because you're adding dependency on the order in which headers are included in that file, as you can see, its easy to get the order wrong and its giving you error messages. For example, you are including extTime.h before time.h, but class extTime inherits from class time. This kind of problem won't happen if you include your headers in the appropriate files


As an aside, stdafx.h is used by Visual studio for precompiled headers (Not something you really need); you can disable it in the properties of your project

This post has been edited by Bench: 12 November 2009 - 03:49 AM

Was This Post Helpful? 0
  • +
  • -

#11 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

Re: What causes

Posted 12 November 2009 - 03:52 AM

wish I could do that but I have to have the headers this way but if in stdafx.h if I do not put them in the right order that can cause errors? If so thats probably part of my problem
Was This Post Helpful? 0
  • +
  • -

#12 hackterr  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 293
  • Joined: 13-August 09

Re: What causes

Posted 12 November 2009 - 03:56 AM

read my edited post above
Was This Post Helpful? 0
  • +
  • -

#13 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

Re: What causes

Posted 12 November 2009 - 04:09 AM

Wow did that just make a huge difference, Thanks didn't know that about the order on the stdafx.h I bow down to you both ;)

here is new code
stdafx.h
#pragma once

#ifndef _WIN32_WINNT			// Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600	 // Change this to the appropriate value to target other versions of Windows.
#endif


#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <string>
using namespace std;

#include "time.h"
#include "extTime.h"

// TODO: reference additional headers your program requires here



time.h
#pragma once

#include "stdafx.h"

class time
{
public:
	time();//the default constructor
	time(int hrs, int min, char zone);// constructor with parameters
	~time(void);//deconstructor
	void setHour(int hrs);//sets the hour
	void setMinute(int mins);//sets the minute
	int getHour();//gets the hour and returns a value
	int getMinute();//gets the minute and returns a value	
	void incrementHrs();//increments the hour
	void incrementMin();//incrememts the minute
	void printTime();//prints the hour and the minute

protected:
	int hour;//declares the hour
	int minute;//declares the minute
	char timeZone;//declares the time zone
};



time.cpp
#include "stdafx.h"

time::time()//implementation of the default constructor
{
	hour = 0;
	minute = 0;
}
time::time(int hrs, int mins, char tZone)//implementation of the constructor with parameters
{
	hour = hrs;
	minute = mins;
}
time::~time(void)
{
}
void time::setHour(int hrs)
{
	hour = hrs;
}
void time::setMinute(int mins)
{
	minute = mins;
}
int time::getHour()
{
	return hour;	
}
int time::getMinute()
{
	return minute;
}
void time::printTime()
{
	//note from the if statements that consideration
	//is taken whether the hours and minutes are 1 or 2 digits
	if (hour < 10)
		cout << "0";
	cout << hour << ":";
	hour = 0;
	if (minute < 10)
		cout << "0";
	cout << minute << ":";
}
void time::incrementHrs()
{
	hour++;
		if (hour > 23)
			hour = 0;
}
void time::incrementMin()
{
	minute++;
	if (minute > 59)
		minute = 0;
}



extTime.h
#pragma once

#include "stdafx.h"
#include "time.h"

class extTime : public time
{
public:
	extTime();//default constructor
	extTime(int hr, int min, string tZone);//constructor with parameters
	~extTime(void);//destructor
	string getTimeZone();
	void printTime();//redefining the print member function of the base class
private:
	string tZone;//a new data member specific to the derived class
				  //this assumes time zone is denoted by one character
};



extTime.cpp
#include "stdafx.h"

extTime::extTime(void)
{
	if (tZone == "PST")
		cout << "The time is " << (getHour()-3) << ":" << getMinute() << endl;
	if (tZone == "MST")
		cout << "The time is " << (getHour()-2) << ":" << getMinute() << endl;
	if (tZone == "CST")
		cout << "The time is " << (getHour()-1) << ":" << getMinute() << endl;
	if (tZone == "EST")
		cout << "The time is " << getHour() << ":" << getMinute() << endl;
}
extTime::extTime(int hr, int min, string tZone)
{
	hour = hr;
	minute = min;
	timeZone = tZone;
}
extTime::~extTime(void)
{
}
string extTime::getTimeZone()
{
	cout << endl << "Please enter the time zone abbreviation":
	cin >> timeZone;
	return timeZone;
}
void extTime::printTime()
{
	time::printTime();//which will invoke the original printing function from the base class
	cout << ";Time Zone = " << timeZone;
}



main .cpp

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{//starts main

	//call set time
	//create a time object
	//call time for object
	//set time for object
	//increment time and display new time

	//create a ext time object
	//call time for new object
	//set time for object
	//increment the time for the object
	//show a time zone change	

system("pause");//put in a system puase
	return 0;//returns 0 errors
}//ends main




here are the new errors

Error 4 error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it)' : cannot convert parameter 1 from 'char' to 'std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 27
Error 1 error C2440: '=' : cannot convert from 'std::string' to 'char' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 18
Error 2 error C2143: syntax error : missing ';' before ':' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 25
Error 3 error C2143: syntax error : missing ';' before ':' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 25


now what?

I need to know how to get rid of error 4 and error 1, I believe if I kill those 2 then the other 2 will disappear
Was This Post Helpful? 0
  • +
  • -

#14 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

Re: What causes

Posted 12 November 2009 - 04:38 AM

got rid of 2 erorrs got 2 left I don't understand what they mean and need assistance with them

here are the 2 errors

Error 2 error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it)' : cannot convert parameter 1 from 'char' to 'std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 27
Error 1 error C2440: '=' : cannot convert from 'std::string' to 'char' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\week3lab_g.thomaswilsoniii\week3lab_g.thomaswilsoniii\exttime.cpp 18
Was This Post Helpful? 0
  • +
  • -

#15 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 258
  • Joined: 19-September 09

Re: What causes

Posted 12 November 2009 - 05:19 AM

Wooooohooooo I got it to compile with some help of one of my friends now I just need to make the main;)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2