Dumb question but is there any difference between [I]myVariable1[/I] and [I]myVariable2[/I] in the following:
[code]class ExampleClass
{
private myVariable1;
myVariable2;
// Code
}[/code]
this is c#
[QUOTE=Pelf;42470888]Dumb question but is there any difference between [i]myVariable1[/i] and [I]myVariable2[/I] in the following:
[code]class ExampleClass
{
private myVariable1;
myVariable2;
// Code
}[/code][/QUOTE]
Which language is that?
c#
sorry, should have said that
[QUOTE=Pelf;42470888]Dumb question but is there any difference between [i]myVariable1[/i] and [I]myVariable2[/I] in the following:
[code]class ExampleClass
{
private myVariable1;
myVariable2;
// Code
}[/code][/QUOTE]
If that is C++ which I assume it is there would be no difference as the default for members of classes in C++ is private anyway. Had it been a struct however it would make a difference as variables default to public
[editline]10th October 2013[/editline]
I think the same counts for C# but I've never used it so I'm not 100% sure
[QUOTE=Pelf;42470989]c#
sorry, should have said that[/QUOTE]
Then everything usually defaults to least-visible, in this case private.
Most advanced formatting tools make visibility explicit by default though.
Well, both are invalid C# since the type is missing :P
The default accessibility for class members is private.
[editline]10th October 2013[/editline]
:ninja:
[editline]10th October 2013[/editline]
[QUOTE=FPSMango;42471017]If that is C++ which I assume it is there would be no difference as the default for members of classes in C++ is private anyway. Had it been a struct however it would make a difference as variables default to public
[editline]10th October 2013[/editline]
I think the same counts for C# but I've never used it so I'm not 100% sure[/QUOTE]
In C# it'd be private for structs as well.
So, I have a problem with Visual Studio 2012. Usually When I create a class in C++ and choose to implement with a separate .h and .cpp I have no problem I simply use my #include <Header.h> in my .cpp and can continue no problem. However, when I create a template class with separate .h and .cpp it never seems to compile correctly.
Can someone explain why this error is occurring and how to fix it?
I get errors such as:
[QUOTE]1>------ Build started: Project: lab6, Configuration: Debug Win32 ------
1> BinaryNode.cpp
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(12): error C2995: 'BinaryNode<ItemType>::BinaryNode(void)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(20) : see declaration of 'BinaryNode<ItemType>::BinaryNode'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(17): error C2995: 'BinaryNode<ItemType>::BinaryNode(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(21) : see declaration of 'BinaryNode<ItemType>::BinaryNode'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(23): error C2995: 'BinaryNode<ItemType>::BinaryNode(const ItemType &,BinaryNode<ItemType> *,BinaryNode<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(22) : see declaration of 'BinaryNode<ItemType>::BinaryNode'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(29): error C2995: 'void BinaryNode<ItemType>::setItem(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(26) : see declaration of 'BinaryNode<ItemType>::setItem'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(35): error C2995: 'ItemType BinaryNode<ItemType>::getItem(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(27) : see declaration of 'BinaryNode<ItemType>::getItem'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(41): error C2995: 'bool BinaryNode<ItemType>::isLeaf(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(29) : see declaration of 'BinaryNode<ItemType>::isLeaf'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(47): error C2995: 'void BinaryNode<ItemType>::setLeftChildPtr(BinaryNode<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(34) : see declaration of 'BinaryNode<ItemType>::setLeftChildPtr'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(53): error C2995: 'void BinaryNode<ItemType>::setRightChildPtr(BinaryNode<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(35) : see declaration of 'BinaryNode<ItemType>::setRightChildPtr'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(59): error C2995: 'BinaryNode<ItemType> *BinaryNode<ItemType>::getLeftChildPtr(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(31) : see declaration of 'BinaryNode<ItemType>::getLeftChildPtr'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.cpp(65): error C2995: 'BinaryNode<ItemType> *BinaryNode<ItemType>::getRightChildPtr(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynode.h(32) : see declaration of 'BinaryNode<ItemType>::getRightChildPtr'
1> Generating Code...
1> Compiling...
1> BinaryNodeTree.cpp
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarytreeinterface.h(64): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarytreeinterface.h(79) : see reference to class template instantiation 'BinaryTreeInterface<ItemType>' being compiled
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(82): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(101) : see reference to class template instantiation 'BinaryNodeTree<ItemType>' being compiled
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(87): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(290): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(324): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(22): error C2995: 'int BinaryNodeTree<ItemType>::getHeightHelper(BinaryNode<ItemType> *) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(28) : see declaration of 'BinaryNodeTree<ItemType>::getHeightHelper'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(32): error C2995: 'int BinaryNodeTree<ItemType>::getNumberOfNodesHelper(BinaryNode<ItemType> *) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(29) : see declaration of 'BinaryNodeTree<ItemType>::getNumberOfNodesHelper'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(58): error C2995: 'BinaryNode<ItemType> *BinaryNodeTree<ItemType>::balancedAdd(BinaryNode<ItemType> *,BinaryNode<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(36) : see declaration of 'BinaryNodeTree<ItemType>::balancedAdd'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(91): error C2995: 'BinaryNode<ItemType> *BinaryNodeTree<ItemType>::moveValuesUpTree(BinaryNode<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(47) : see declaration of 'BinaryNodeTree<ItemType>::moveValuesUpTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(124): error C2995: 'BinaryNode<ItemType> *BinaryNodeTree<ItemType>::removeValue(BinaryNode<ItemType> *,const ItemType,bool &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(41) : see declaration of 'BinaryNodeTree<ItemType>::removeValue'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(149): error C2995: 'BinaryNode<ItemType> *BinaryNodeTree<ItemType>::findNode(BinaryNode<ItemType> *,const ItemType &,bool &) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(51) : see declaration of 'BinaryNodeTree<ItemType>::findNode'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(166): error C2995: 'BinaryNode<ItemType> *BinaryNodeTree<ItemType>::copyTree(const BinaryNode<ItemType> *) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(57) : see declaration of 'BinaryNodeTree<ItemType>::copyTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(177): error C2995: 'void BinaryNodeTree<ItemType>::destroyTree(BinaryNode<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(32) : see declaration of 'BinaryNodeTree<ItemType>::destroyTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(193): error C2995: 'void BinaryNodeTree<ItemType>::preorder(void (__cdecl *)(ItemType &),BinaryNode<ItemType> *) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(60) : see declaration of 'BinaryNodeTree<ItemType>::preorder'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(205): error C2995: 'void BinaryNodeTree<ItemType>::inorder(void (__cdecl *)(ItemType &),BinaryNode<ItemType> *) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(61) : see declaration of 'BinaryNodeTree<ItemType>::inorder'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(217): error C2995: 'void BinaryNodeTree<ItemType>::postorder(void (__cdecl *)(ItemType &),BinaryNode<ItemType> *) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(62) : see declaration of 'BinaryNodeTree<ItemType>::postorder'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(230): error C2995: 'BinaryNodeTree<ItemType>::BinaryNodeTree(void)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(68) : see declaration of 'BinaryNodeTree<ItemType>::BinaryNodeTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(236): error C2995: 'BinaryNodeTree<ItemType>::BinaryNodeTree(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(69) : see declaration of 'BinaryNodeTree<ItemType>::BinaryNodeTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(245): error C2995: 'BinaryNodeTree<ItemType>::BinaryNodeTree(const ItemType &,const BinaryNodeTree<ItemType> *,const BinaryNodeTree<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(70) : see declaration of 'BinaryNodeTree<ItemType>::BinaryNodeTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(251): error C2995: 'BinaryNodeTree<ItemType>::BinaryNodeTree(const BinaryNodeTree<ItemType> &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(73) : see declaration of 'BinaryNodeTree<ItemType>::BinaryNodeTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(257): error C2995: 'BinaryNodeTree<ItemType>::~BinaryNodeTree(void)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(74) : see declaration of 'BinaryNodeTree<ItemType>::~BinaryNodeTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(268): error C2995: 'bool BinaryNodeTree<ItemType>::isEmpty(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(79) : see declaration of 'BinaryNodeTree<ItemType>::isEmpty'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(274): error C2995: 'int BinaryNodeTree<ItemType>::getHeight(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(80) : see declaration of 'BinaryNodeTree<ItemType>::getHeight'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(280): error C2995: 'int BinaryNodeTree<ItemType>::getNumberOfNodes(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(81) : see declaration of 'BinaryNodeTree<ItemType>::getNumberOfNodes'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(287): error C2995: 'void BinaryNodeTree<ItemType>::clear(void)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(86) : see declaration of 'BinaryNodeTree<ItemType>::clear'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(296): error C2995: 'ItemType BinaryNodeTree<ItemType>::getRootData(void) throw(PrecondViolatedExcep) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(82) : see declaration of 'BinaryNodeTree<ItemType>::getRootData'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(305): error C2995: 'void BinaryNodeTree<ItemType>::setRootData(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(83) : see declaration of 'BinaryNodeTree<ItemType>::setRootData'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(313): error C2995: 'bool BinaryNodeTree<ItemType>::add(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(84) : see declaration of 'BinaryNodeTree<ItemType>::add'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(321): error C2995: 'bool BinaryNodeTree<ItemType>::remove(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(85) : see declaration of 'BinaryNodeTree<ItemType>::remove'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(333): error C2995: 'ItemType BinaryNodeTree<ItemType>::getEntry(const ItemType &) throw(NotFoundException) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(87) : see declaration of 'BinaryNodeTree<ItemType>::getEntry'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(341): error C2995: 'bool BinaryNodeTree<ItemType>::contains(const ItemType &) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(88) : see declaration of 'BinaryNodeTree<ItemType>::contains'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(351): error C2995: 'void BinaryNodeTree<ItemType>::preorderTraverse(void (__cdecl *)(ItemType &)) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(93) : see declaration of 'BinaryNodeTree<ItemType>::preorderTraverse'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(357): error C2995: 'void BinaryNodeTree<ItemType>::inorderTraverse(void (__cdecl *)(ItemType &)) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(94) : see declaration of 'BinaryNodeTree<ItemType>::inorderTraverse'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(363): error C2995: 'void BinaryNodeTree<ItemType>::postorderTraverse(void (__cdecl *)(ItemType &)) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(95) : see declaration of 'BinaryNodeTree<ItemType>::postorderTraverse'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(377): error C2995: 'BinaryNodeTree<ItemType> &BinaryNodeTree<ItemType>::operator =(const BinaryNodeTree<ItemType> &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(100) : see declaration of 'BinaryNodeTree<ItemType>::operator ='
1> Generating Code...
1> Compiling...
1> BinarySearchTree.cpp
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarytreeinterface.h(64): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarytreeinterface.h(79) : see reference to class template instantiation 'BinaryTreeInterface<ItemType>' being compiled
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(82): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(101) : see reference to class template instantiation 'BinaryNodeTree<ItemType>' being compiled
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(87): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(290): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(324): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(71): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(90) : see reference to class template instantiation 'BinarySearchTree<ItemType>' being compiled
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(72): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(76): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(240): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(250): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(274): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(31): error C2995: 'BinaryNode<ItemType> *BinarySearchTree<ItemType>::insertInorder(BinaryNode<ItemType> *,BinaryNode<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(31) : see declaration of 'BinarySearchTree<ItemType>::insertInorder'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(62): error C2995: 'BinaryNode<ItemType> *BinarySearchTree<ItemType>::removeValue(BinaryNode<ItemType> *,const ItemType,bool &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(36) : see declaration of 'BinarySearchTree<ItemType>::removeValue'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(123): error C2995: 'BinaryNode<ItemType> *BinarySearchTree<ItemType>::removeNode(BinaryNode<ItemType> *)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(42) : see declaration of 'BinarySearchTree<ItemType>::removeNode'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(139): error C2995: 'BinaryNode<ItemType> *BinarySearchTree<ItemType>::removeLeftmostNode(BinaryNode<ItemType> *,ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(48) : see declaration of 'BinarySearchTree<ItemType>::removeLeftmostNode'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(174): error C2995: 'BinaryNode<ItemType> *BinarySearchTree<ItemType>::findNode(BinaryNode<ItemType> *,const ItemType &) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(53) : see declaration of 'BinarySearchTree<ItemType>::findNode'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(189): error C2995: 'BinarySearchTree<ItemType>::BinarySearchTree(void)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(60) : see declaration of 'BinarySearchTree<ItemType>::BinarySearchTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(195): error C2995: 'BinarySearchTree<ItemType>::BinarySearchTree(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(61) : see declaration of 'BinarySearchTree<ItemType>::BinarySearchTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(201): error C2995: 'BinarySearchTree<ItemType>::BinarySearchTree(const BinarySearchTree<ItemType> &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(62) : see declaration of 'BinarySearchTree<ItemType>::BinarySearchTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(207): error C2995: 'BinarySearchTree<ItemType>::~BinarySearchTree(void)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(63) : see declaration of 'BinarySearchTree<ItemType>::~BinarySearchTree'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(218): error C2995: 'bool BinarySearchTree<ItemType>::isEmpty(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(68) : see declaration of 'BinarySearchTree<ItemType>::isEmpty'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(224): error C2995: 'int BinarySearchTree<ItemType>::getHeight(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(69) : see declaration of 'BinarySearchTree<ItemType>::getHeight'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(230): error C2995: 'int BinarySearchTree<ItemType>::getNumberOfNodes(void) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(70) : see declaration of 'BinarySearchTree<ItemType>::getNumberOfNodes'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(237): error C2995: 'void BinarySearchTree<ItemType>::clear(void)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(75) : see declaration of 'BinarySearchTree<ItemType>::clear'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(246): error C2995: 'ItemType BinarySearchTree<ItemType>::getRootData(void) throw(PrecondViolatedExcep) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(71) : see declaration of 'BinarySearchTree<ItemType>::getRootData'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(253): error C2995: 'void BinarySearchTree<ItemType>::setRootData(const ItemType &) throw(PrecondViolatedExcep) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(72) : see declaration of 'BinarySearchTree<ItemType>::setRootData'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(262): error C2995: 'bool BinarySearchTree<ItemType>::add(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(73) : see declaration of 'BinarySearchTree<ItemType>::add'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(270): error C2995: 'bool BinarySearchTree<ItemType>::remove(const ItemType &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(74) : see declaration of 'BinarySearchTree<ItemType>::remove'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(281): error C2995: 'ItemType BinarySearchTree<ItemType>::getEntry(const ItemType &) throw(NotFoundException) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(76) : see declaration of 'BinarySearchTree<ItemType>::getEntry'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(289): error C2995: 'bool BinarySearchTree<ItemType>::contains(const ItemType &) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(77) : see declaration of 'BinarySearchTree<ItemType>::contains'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(300): error C2995: 'void BinarySearchTree<ItemType>::preorderTraverse(void (__cdecl *)(ItemType &)) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(82) : see declaration of 'BinarySearchTree<ItemType>::preorderTraverse'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(306): error C2995: 'void BinarySearchTree<ItemType>::inorderTraverse(void (__cdecl *)(ItemType &)) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(83) : see declaration of 'BinarySearchTree<ItemType>::inorderTraverse'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(312): error C2995: 'void BinarySearchTree<ItemType>::postorderTraverse(void (__cdecl *)(ItemType &)) const' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(84) : see declaration of 'BinarySearchTree<ItemType>::postorderTraverse'
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(328): error C2995: 'BinarySearchTree<ItemType> &BinarySearchTree<ItemType>::operator =(const BinarySearchTree<ItemType> &)' : function template has already been defined
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(89) : see declaration of 'BinarySearchTree<ItemType>::operator ='
1> Generating Code...
1> Compiling...
1> lab6.cpp
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarytreeinterface.h(64): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarytreeinterface.h(79) : see reference to class template instantiation 'BinaryTreeInterface<ItemType>' being compiled
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(82): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(101) : see reference to class template instantiation 'BinaryNodeTree<ItemType>' being compiled
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.h(87): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(290): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarynodetree.cpp(324): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(71): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(90) : see reference to class template instantiation 'BinarySearchTree<ItemType>' being compiled
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(72): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.h(76): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(240): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(250): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(274): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
1>c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(288): warning C4800: 'BinaryNode<ItemType> *' : forcing value to bool 'true' or 'false' (performance warning)
1> with
1> [
1> ItemType=std::string
1> ]
1> c:\users\omive_000\documents\visual studio 2012\projects\lab6\lab6\binarysearchtree.cpp(286) : while compiling class template member function 'bool BinarySearchTree<ItemType>::contains(const ItemType &) const'
1> with
1> [
1> ItemType=std::string
1> ]
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[/QUOTE]
I don't even know C++ but after a very quick search I found that set.h references set.cpp and set.cpp references set.h, so if you include .h in your .ccp it's a loop that keeps creating a new .cpp which creates a new .h which creates a new .cpp etc..
More information could be found [URL="http://stackoverflow.com/questions/11094310/error-c2995-function-template-has-already-been-defined"]here[/URL]
Basically i'm trying to make 2d platformer collision.
Whenever I try to make collision detection between a movable player and a wall I can get them to collide and return true, and I can set the players speed to 0 so it doesn't go into the wall. But then I can't move anymore since I changed the speed to 0. How do I make it so that when the player hits the wall it cant move that direction any more but I can still move away from the wall.
Sorry if this is confusing to understand.
I'm using libgdx in java.
Roughly
[code]if(collision)
{
set position just in front of the object
}
else
{
update position normally
}[/code]
what is the best way to develop a lighting system in a 2D game?
Using C# and Visual Studios
[QUOTE=ZeekyHBomb;42478677]Roughly
[code]if(collision)
{
set position just in front of the object
}
else
{
update position normally
}[/code][/QUOTE]
Thank you so much, I feel stupid by how simple it was.
[QUOTE=elih595;42478816]Thank you so much, I feel stupid by how simple it was.[/QUOTE]
Trust me, it seems simple when it's put like that but it'll get wildly complex.
[C++] I need some help with the mastermind game on how to check for correctness.
So I got an assignment in which I need to create a mastermind game. For the most part, setting it up isn't an issue. Just one catch, I can't use arrays, pointers, and anything else. Just can only use functions, if statements, and loops.
If we were using arrays, it wouldn't be a problem, but I don't know how to create the program without arrays.
This would be one with black pegs and white pegs. Black pegs where the number is in the correct spot, and white pegs when the number is correct, but wrong spot. In addition, we only have 4 digits, so it would be something like: 5632 (only numbers from 1 - 6). Except that number is suppose to be obtained using a rand function.
How would I go about solving this? Basically, I started off by multiplying rands by 1000, 100, 10, and 1 to obtain the 5632 (random number). But after I obtain the number, I'm not sure how to check the user's input to see if it matches the random number.
Any help would be greatly appreciated, I'm not sure how to start. My original guess was to divide up the numbers by 1000, 100, 10, and 1 to check the numbers. But I think that's too tedious, and not correct.
A sample run is something like this:
Guess: 5134
1 black peg, and 3 white peg.
Guess: 5341
2 black peg, and 2 white peg.
Guess: 5314
4 black peg, and 0 white peg.
You win!
[QUOTE=Leonmyster;42484506]
Any help would be greatly appreciated, I'm not sure how to start. My original guess was to divide up the numbers by 1000, 100, 10, and 1 to check the numbers. But I think that's too tedious, and not correct.
A sample run is something like this:
Guess: 5134
1 black peg, and 3 white peg.
Guess: 5341
2 black peg, and 2 white peg.
Guess: 5314
4 black peg, and 0 white peg.
You win![/QUOTE]
Based on those ridiculous restrictions, dividing by powers of ten to extract individual digits is a perfectly reasonable solution. The only thing I can think of to make it a bit easier is if you think of the numbers as being in hexadecimal, then you can read/write digits using bitwise operators.
You could also always work with digits instead of the number, then just concatenate them when writing to the console.
Getting four random digits is the same as getting one four-digit number for the purposes of the specification, as long as you don't accidentally reseed the RNG with the same value between draws.
My Visual Studio 2010 crashes after profiling (after the processing when it's about to show results), anyone know where i can find logs?
I have my build process on linux to work with local copies of the library files:
(in premake)
[code]
if _ACTION == "gmake" then
libdirs { "./external/lib/linux" }
end
[/code]
And then jenkins just builds it all, however when it uses the local copies It fails with:
[code]
==== Building StandAlone (debug) ====
Creating obj/Debug/StandAlone
Program.cpp
Main.cpp
Linking StandAlone
/usr/bin/ld:../external/lib/linux/libsfml-window.so: file format not recognized; treating as linker script
/usr/bin/ld:../external/lib/linux/libsfml-window.so:1: syntax error
collect2: ld returned 1 exit status
make[1]: *** [../bin/Debug/StandAlone] Error 1
make: *** [StandAlone] Error 2
Build step 'Execute shell' marked build as failure[/code]
Yet the exact same libraries are also installed in /usr/local/lib and when using these, it runs fine.
Ideallly I would want it building with the local copies.
Perhaps an 64-bit vs 32-bit issue? Although I'd think that ld would still recognize it and output a better error.
You could try to run objdump on it, as kind of a way to check its integrity. Although if these are the exact same libraries you can diff them to make sure there wasn't anything funny going on when the shared object was placed there.
sO i'm working on a build heap code and I'm in need of some help..
[QUOTE=ZeekyHBomb;42493772]Perhaps an 64-bit vs 32-bit issue? Although I'd think that ld would still recognize it and output a better error.
You could try to run objdump on it, as kind of a way to check its integrity. Although if these are the exact same libraries you can diff them to make sure there wasn't anything funny going on when the shared object was placed there.[/QUOTE]
Hmm
[code]
objdump -s ../external/lib/linux/libsfml-window.so
objdump: ../external/lib/linux/libsfml-window.so: File format not recognized
[/code]
Could it be because the .so file is a symlink to so.2 which is also a simlink to the actual library .so.2.1
Couldnt get the dif tool to work, but doing a cat of the local symlink returned: libsfml-window-so.2
where as doing cat of the installed one returned lots of random stuff, are symlinks relative, or do they expect an absolute directory?
[editline]12th October 2013[/editline]
I seem to have gotten around this issue by renaming the library files AKA the .so.2.1 files to just .so
symlinks can be both, relative or absolute. You can look where it goes via ls -l. edit: or readlink
And you can also chain symlinks (although I think only up to some depth, should be fairly high though).
You can also use the file-tool to check the type of a file. It does that by checking the first few bytes against a database afaik.
How does the Color arg in XNA's SpriteBatch.Draw work. I've been trying to achieve something similar in GDI+ using,
[code]
int red = (pixel.R + Color.R) / 2;
int green = (pixel.G + Color.G) / 2;
int blue = (pixel.B + Color.B) / 2;
[/code]
on the pixels to color the image but the end result kinda correct but much brighter then what you would see in a DirectX render of the same image + color.
I'm trying to convert a std::string into separate virtual key codes.
I managed to cut the string into its individual characters, but I'm stuck with converting them into the vKcs.
Does anyone have an idea how I would go about doing this? In c++ I might add.
[QUOTE=anthonywolfe;42512281]How does the Color arg in XNA's SpriteBatch.Draw work. I've been trying to achieve something similar in GDI+ using,
[code]
int red = (pixel.R + Color.R) / 2;
int green = (pixel.G + Color.G) / 2;
int blue = (pixel.B + Color.B) / 2;
[/code]
on the pixels to color the image but the end result kinda correct but much brighter then what you would see in a DirectX render of the same image + color.[/QUOTE]
It specifies a tint, meaning the color gets multiplied to each pixel of the sprite.
[QUOTE=LennyPenny;42512413]I'm trying to convert a std::string into separate virtual key codes.
I managed to cut the string into its individual characters, but I'm stuck with converting them into the vKcs.
Does anyone have an idea how I would go about doing this? In c++ I might add.[/QUOTE]
Can you give an example string and the expected output?
[QUOTE=ZeekyHBomb;42512595]
Can you give an example string and the expected output?[/QUOTE]
"Hey"
0x48, 0x45, 0x59
What type is the output? Also a string?
A WORD according to this: [url]http://msdn.microsoft.com/en-us/library/windows/desktop/ms646271(v=vs.85).aspx[/url]
[QUOTE=LennyPenny;42513175]A WORD according to this: [url]http://msdn.microsoft.com/en-us/library/windows/desktop/ms646271(v=vs.85).aspx[/url][/QUOTE]
Which is an integer iirc.
What are you actually trying to do? You can't just convert a character to a virtual key code, it doesn't make sense. If you're trying to get the keys pressed that resulted in a certain character then you'll need to ask windows, if it's even possible.
If you want to convert a string like "A" or "1" or "Escape" to the key code then you'll just have to do it yourself.
If you wanted to input text to a window then send WM_CHAR messages.
Sorry, you need to Log In to post a reply to this thread.