Classes & Inheritance

Alright so in Visual Studio 10, my program compiles okay. But IntelliSense is telling me that there's errors in my project.

[Grad.cpp] - The errors are here
1 IntelliSense: name followed by '::' must be a class or namespace name c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 3
2 IntelliSense: name followed by '::' must be a class or namespace name c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 3
3 IntelliSense: name followed by '::' must be a class or namespace name c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 4
4 IntelliSense: name followed by '::' must be a class or namespace name c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 4
5 IntelliSense: identifier "istream" is undefined c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 6
6 IntelliSense: identifier "istream" is undefined c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 6
7 IntelliSense: identifier "cout" is undefined c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 9
8 IntelliSense: identifier "endl" is undefined c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 9
9 IntelliSense: identifier "homework" is undefined c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 11
10 IntelliSense: identifier "min" is undefined c:\users\dj\documents\visual studio 2010\projects\13.1 - inheritance\13.1 - inheritance\grad.cpp 18

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "Grad.h"

using std::istream; using std::cout;
using std::endl; using std::min;

istream& Grad::read(istream& in)
{
	read_common(in);
	cout << "Enter student's thesis mark." << endl;
	in >> thesis;
	read_hw(in, homework);
	return in;
}

double Grad::grade() const
{
	// Core:: is a scope operator
	return min(Core::grade(), thesis);
}


Which includes this:
[Grade.h]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef GUARD_Grad_h

#define GUARD_Grad_h

#include "Core.h"

class Grad: public Core
{
public:
	Grad();
	Grad(std::istream&);
	double grade() const;
	std::istream& read(std::istream&);
private:
	double thesis;
};

#endif 


Which includes the base class Core
[Core.h]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef GUARD_Core_h

#define GUARD_Core_h

#include <iostream>
#include <string>
#include <vector>

class Core
{
	// Friends
	friend double grade(const Core&);
public:
	Core();
	Core(std::istream&);
	std::string name() const;
	std::istream& read(std::istream&);
	double grade() const;
	bool valid() const { return !homework.empty(); }
protected:
	std::istream& read_common(std::istream&);
	double midterm, final;
	std::vector<double> homework;
private:
	std::string n;
};

bool compare(const Core&, const Core&);
std::istream& read_hw(std::istream&, std::vector<double>&);

#endif 


I also got similar errors in the Core.cpp file. Should I just disable Intellisense or is it because my code is written not properly? It's a bit annoying to see these red underlinings.

I also notice that the external dependencies folder is empty in my project. And my std includes have Intellisense warnings. IntelliSense: cannot open source file "vector". But I STILL CAN compile.


Nevermind, I just copied all my code into a new project and it seems to be working now. I guess that project was corrupt or something.
Last edited on
A universal solution to those problems is deleting the .ncb file!
Topic archived. No new replies allowed.