09.09.2016, 13:55. Просмотров 167. Ответов 2
C++ |
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
32
33
34
| #include <iostream>
using std:: cin;
using std:: cout;
using std:: endl;
struct NodePtr
{
char Value;
NodePtr* Next;
};
int main()
{
char Ch;
NodePtr Node, First, Last, Curr, Tmp;
cout << "Enter speed, plz" << endl;
do
{
cin.get(Ch);
if (Ch != '\n')
{
cout << Ch << endl;
NodePtr* Node = new NodePtr;
Node -> Value = Ch;
Node -> Next = NULL;
First = Node;
Last = Node;
}
}
while (Ch != '\n');
return 0;
} |
|
Пробую реализовать стек на указателях. Но файл не компилируется:
1>------ Build started: Project: task5, Configuration: Debug Win32 ------
1>Compiling...
1>task5.cpp
1>c:\visual studio 2008\projects\lab1\07.09.16\task5\task5\task5.cpp(27) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'NodePtr *' (or there is no acceptable conversion)
1> c:\visual studio 2008\projects\lab1\07.09.16\task5\task5\task5.cpp(10): could be 'NodePtr &NodePtr::operator =(const NodePtr &)'
1> while trying to match the argument list '(NodePtr, NodePtr *)'
1>c:\visual studio 2008\projects\lab1\07.09.16\task5\task5\task5.cpp(28) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'NodePtr *' (or there is no acceptable conversion)
1> c:\visual studio 2008\projects\lab1\07.09.16\task5\task5\task5.cpp(10): could be 'NodePtr &NodePtr::operator =(const NodePtr &)'
1> while trying to match the argument list '(NodePtr, NodePtr *)'
1>Build log was saved at "file://c:\Visual Studio 2008\Projects\Lab1\07.09.16\task5\task5\Debug\BuildLog.htm"
1>task5 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
А еще не понятно как сделать проверку на существование первого элемента в стеке. Когда пишу:
if (First -> Value == NULL)
{...}
Компилятор ругается снова((...