On 15.07.2016 17:51, Denise James wrote:
> Hello, I am getting an error in Eclipse, error: expected initializer
> before 'CAlley', along with warnings such as "will be initialized
> after [-Wreorder]"
>
Here are the errors reported by Visual C++ 2015:
> original.cpp(114): error C2248: 'CarNode::m_ticketNum': cannot access private member declared in class 'CarNode'
> original.cpp(24): note: see declaration of 'CarNode::m_ticketNum'
> original.cpp(8): note: see declaration of 'CarNode'
> original.cpp(115): error C2248: 'CarNode::m_pNext': cannot access private member declared in class 'CarNode'
> original.cpp(23): note: see declaration of 'CarNode::m_pNext'
> original.cpp(8): note: see declaration of 'CarNode'
> original.cpp(216): error C2660: 'CAlley::Display': function does not take 0 arguments
I used the following default options, in environment variable CL:
> CL=/nologo /EHsc /GR /W4 /FI "iso646.h"
Here are the errors reported by MinGW g++ 5.1.0:
> original.cpp: In member function 'CarNode* CAlley::Pop()':
> original.cpp:94:1: warning: no return statement in function returning non-void [-Wreturn-type]
> }
> ^
> original.cpp: In member function 'int CAlley::Park(int)':
> original.cpp:24:6: error: 'int CarNode::m_ticketNum' is private
> int m_ticketNum; // ticket number of car
> ^
> original.cpp:114:19: error: within this context
> NewNode.m_ticketNum = userTicketNum;
> ^
> original.cpp:23:11: error: 'CarNode* CarNode::m_pNext' is private
> CarNode *m_pNext; // pointer to next node in stack
> ^
> original.cpp:115:19: error: within this context
> NewNode.m_pNext = nullptr; // the next node is empty
> ^
> original.cpp:118:1: warning: no return statement in function returning non-void [-Wreturn-type]
> }
> ^
> original.cpp: In function 'int main()':
> original.cpp:216:28: error: no matching function for call to 'CAlley::Display()'
> AlleyA.Display();
> ^
> original.cpp:162:6: note: candidate: void CAlley::Display(char*)
> void CAlley::Display(char *)
I used the following default options, in command alias g++ (via doskey):
> g++=g++ -std=c++14 -pedantic-errors -Wall -Wextra -fexec-charset=cp1252 $*
Mostly the options tell each compiler to be a bit more
standard-conforming than it is by default, and to produce more warnings,
please.
It's generally a good idea to use at least two compilers. When one
compiler's error messages are incomprehensible, the other compiler might
be able to shed some light on the problem. Also, it helps to produce
more portable code.
Cheers & hth.,
- Alf