Указатель int
отличается от int
. Вы не можете назначить указатели на целые числа без некоторых неприятных уловок. Я приведу несколько примеров того, что вы, вероятно, хотите сделать.
Пример указателя:
#include <iostream>
using namespace std;
int main()
{
int ted = 5;
int andy = 6;
int * ptr = &andy;
cout << "ted: " << ted << endl;
cout << "andy: " << andy << endl;
cout << "ptr: " << *ptr << endl;
}
Пример ссылки:
#include <iostream>
using namespace std;
int main()
{
int ted = 5;
int andy = 6;
int & ref = andy;
cout << "ted: " << ted << endl;
cout << "andy: " << andy << endl;
cout << "ref: " << ref << endl;
}