HI, I'm relatively new to programming in C++. I'm pretty solid in C and Java though.
Anyway, I'm trying to create a class, Mesh, that has a vector full of my other class, Node, however the compiler doesn't seem to like it. I've looked through the console message but I don't have a clue where to start!
Here's the source code thus far:
Node.h:
#pragma once
ref class Node
{
int x, y, z;
bool isBoundary;
public:
Node();
Node(int, int, int);
int getX(){return x;}
int getY(){return y;}
int getZ(){return z;}
};
Mesh.h:
#pragma once
#include "Node.h"
#include <vector>
ref class Mesh
{
int numOfNodes;
public:
Mesh(void);
Mesh(int);
void createNode(int, int, int);
Node getNode(int);
std::vector<Node> meshNodes();
};
The error(s) I'm getting are:
1>------ Build started: Project: MEngProject, Configuration: Debug Win32 ------
1>Compiling...
1>Mesh.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(95) : error C3699: '*' : cannot use this indirection on type 'Node'
1> compiler replacing '*' with '^' to continue parsing
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(429) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
1> with
1> [
1> _Ty=Node
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(439) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled
1> with
1> [
1> _Ty=Node,
1> _Alloc=std::allocator<Node>
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(144) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=Node
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xstring(1270) : see reference to function template instantiation 'std::char_traits<char>::char_type *std::_Traits_helper::move_s<_Traits>(std::char_traits<char>::char_type *,size_t,const std::char_traits<char>::char_type *,size_t)' being compiled
1> with
1> [
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xstring(1262) : while compiling class template member function 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::erase(unsigned int,unsigned int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xstring(2221) : see reference to class template instantiation 'std::basic_string<_Elem,_Traits,_Ax>' being compiled
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(96) : error C3699: '&' : cannot use this indirection on type 'Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(97) : error C3699: '*' : cannot use this indirection on type 'const Node'
1> compiler replacing '*' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(98) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(153) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(486) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(492) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(544) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(808) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(869) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(874) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(881) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1094) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1152) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1252) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1289) : error C3265: cannot declare a managed '_Myfirst' in an unmanaged 'std::vector<_Ty>'
1> with
1> [
1> _Ty=Node
1> ]
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1290) : error C3265: cannot declare a managed '_Mylast' in an unmanaged 'std::vector<_Ty>'
1> with
1> [
1> _Ty=Node
1> ]
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1291) : error C3265: cannot declare a managed '_Myend' in an unmanaged 'std::vector<_Ty>'
1> with
1> [
1> _Ty=Node
1> ]
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>Node.cpp
1>MEngProject.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(95) : error C3699: '*' : cannot use this indirection on type 'Node'
1> compiler replacing '*' with '^' to continue parsing
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(429) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
1> with
1> [
1> _Ty=Node
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(439) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled
1> with
1> [
1> _Ty=Node,
1> _Alloc=std::allocator<Node>
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xlocnum(135) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=Node
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(1598) : see reference to function template instantiation 'void std::_Debug_range2<_InIt>(_RanIt,_RanIt,const wchar_t *,unsigned int,std::random_access_iterator_tag)' being compiled
1> with
1> [
1> _InIt=const std::codecvt<unsigned short,char,_Mbstatet>::_Elem *,
1> _RanIt=const std::codecvt<unsigned short,char,_Mbstatet>::_Elem *
1> ]
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xlocale(1209) : see reference to function template instantiation 'void std::_Debug_range<const std::codecvt<unsigned short,char,_Mbstatet>::_Elem*>(_InIt,_InIt,const wchar_t *,unsigned int)' being compiled
1> with
1> [
1> _InIt=const std::codecvt<unsigned short,char,_Mbstatet>::_Elem *
1> ]
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(96) : error C3699: '&' : cannot use this indirection on type 'Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(97) : error C3699: '*' : cannot use this indirection on type 'const Node'
1> compiler replacing '*' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(98) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(153) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(486) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(492) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(544) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(808) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(869) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(874) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(881) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1094) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1152) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1252) : error C3699: '&' : cannot use this indirection on type 'const Node'
1> compiler replacing '&' with '^' to continue parsing
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1289) : error C3265: cannot declare a managed '_Myfirst' in an unmanaged 'std::vector<_Ty>'
1> with
1> [
1> _Ty=Node
1> ]
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1290) : error C3265: cannot declare a managed '_Mylast' in an unmanaged 'std::vector<_Ty>'
1> with
1> [
1> _Ty=Node
1> ]
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1291) : error C3265: cannot declare a managed '_Myend' in an unmanaged 'std::vector<_Ty>'
1> with
1> [
1> _Ty=Node
1> ]
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>Generating Code...
1>Build log was saved at "file://c:\Users\Dillinger\Documents\Visual Studio 2008\Projects\MEngProject\MEngProject\Debug\BuildLog.htm"
1>MEngProject - 36 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Many thanks for looking!
Dan