"Does not Name a Type" error

  • (2 Pages)
  • +
  • 1
  • 2

28 Replies - 44485 Views - Last Post: 07 August 2009 - 03:06 AM Rate Topic: -----

#1 sdo  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 06-February 09

"Does not Name a Type" error

Post icon  Posted 10 March 2009 - 11:28 AM

Hey All,

So I have:

#include "index.h"

struct Node{
   index dex;
   Node **next;
   int size;
};

And it tells me:

error: 'index' does not name a type

Whats going on?

Thanks,

SDO

This post has been edited by sdo: 10 March 2009 - 11:29 AM

Is This A Good Question/Topic? 0
  • +

Replies To: "Does not Name a Type" error

#2 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 11:31 AM

Is index defined anywhere in your program? C++ doesn't have a type named index.
Was This Post Helpful? 0
  • +
  • -

#3 sdo  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 06-February 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 11:34 AM

Yes, its defined in index.h and index.cpp which I included at the top, is that not sufficient?
Was This Post Helpful? 0
  • +
  • -

#4 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 11:38 AM

Can you post the definition of index from index.h?
Was This Post Helpful? 0
  • +
  • -

#5 sdo  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 06-February 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 11:41 AM

Index.h:

#pragma once
#include <string>
#include <vector>

using namespace std;

class index
{
public:
	index(void);
	index(string,int,int);
	index(const string,int,vector<int>);
	~index(void);

	void increment(void);
	void addPage(int);
	void printIndex(void);
	void printIndexToFile(const string);
	void setWord(const string);

	string getWord(void);
	int getCount(void);
   

private:
	string word;
	int wordCount;
	vector<int> pages;
};

Was This Post Helpful? 0
  • +
  • -

#6 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 11:55 AM

And you're sure you're including index.h?

Also, what compiler are you using?

This post has been edited by bsaunders: 10 March 2009 - 11:56 AM

Was This Post Helpful? 0
  • +
  • -

#7 sdo  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 06-February 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 11:56 AM

You can see my inclusion in my OP. Compiler = g++, it compiles fine on MSVC++

This post has been edited by sdo: 10 March 2009 - 11:57 AM

Was This Post Helpful? 0
  • +
  • -

#8 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: "Does not Name a Type" error

Posted 10 March 2009 - 11:59 AM

Are you passing the proper parameters to g++?
Was This Post Helpful? 0
  • +
  • -

#9 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 12:02 PM

What happens if you replace the #pragma once with macro guards?
Was This Post Helpful? 0
  • +
  • -

#10 sdo  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 06-February 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 12:28 PM

whats with the DIC server telling me I don't have permission to reply to this post all the time? Does anyone else get that?

ok ill try replying yet again..

macro guards didnt help

sorry KYA, every time I try to tell you what compiler paramerters im using, I get a FORBIDDEN URL.. idk whats up with that. I'll just say Im using the standard call

This post has been edited by sdo: 10 March 2009 - 12:29 PM

Was This Post Helpful? 0
  • +
  • -

#11 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 12:28 PM

Quote

whats with the DIC server telling me I don't have permission to reply to this post all the time? Does anyone else get that?


I got that a few times.
Was This Post Helpful? 0
  • +
  • -

#12 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 12:33 PM

What happens if you just comment out the class declaration and declare index as a synonym for type int:

typedef int index;.
Was This Post Helpful? 0
  • +
  • -

#13 sdo  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 06-February 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 12:39 PM

I'm not sure I follow.. I could retain all of the index's class functionality this way?
Was This Post Helpful? 0
  • +
  • -

#14 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 12:44 PM

No, it's just to test if the program compiles if the index type was redefined as an int instead of a class.
Was This Post Helpful? 0
  • +
  • -

#15 sdo  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 06-February 09

Re: "Does not Name a Type" error

Posted 10 March 2009 - 12:47 PM

typdef int index redecalred as different kind of symbol

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2