Программа по вычислениям полностью устраивает, она перемножает 2 матрицы указанного размера с рандомными числами, она запускается и правильно считает, но показывает, что есть ошибки типа: cin, cout, system не являются однозначными, всего 17 ошибок, подчеркивает красным эти операторы, как это убрать?
#include <iostream>
#include <ctime>
#include <iomanip>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
int** P1, ** P2, ** P3, n, m;
cout << "Введите кол-во строк матрицы: ";
cin >> n;
cout << "Введите кол-во столбцов матрицы: ";
cin >> m;
P1 = new int* [n];
for (int i = 0; i < n; i++)
P1[i] = new int[m];
srand(time(0));
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) //рандом 1 матрицы
P1[i][j] = rand() % 10;
for (int i = 0; i < n; i++)
{
cout << endl; //вывод 1 матрицы
for (int j = 0; j < m; j++)
{
cout << setw(3) << P1[i][j] << "t";
}
}
cout << endl;
int k;
cout << "Введите кол-во столбцов 2 матрицы: ";
cin >> k;
P2 = new int* [k];
for (int i = 0; i < m; i++)
P2[i] = new int[k];
for (int i = 0; i < m; i++)
for (int j = 0; j < k; j++) //рандом 2 матрицы
P2[i][j] = rand() % 10;
for (int i = 0; i < m; i++)
{
cout << endl; //вывод 2 матрицы
for (int j = 0; j < k; j++)
{
cout << setw(3) << P2[i][j] << "t";
}
}
cout << endl;
P3 = new int* [n];
for (int i = 0; i < n; i++)
P3[i] = new int[k];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < k; j++) //умножение матриц
{
P3[i][j] = 0;
for (int z = 0; z < m; z++)
P3[i][j] = P3[i][j] + P1[i][z] * P2[z][j];
}
}
cout << endl << "Результат умножения:" << endl;
for (int i = 0; i < n; i++) //вывод результата
умножения
{
cout << endl;
for (int j = 0; j < k; j++)
cout << setw(3) << P3[i][j] << "t";
}
cout << endl;
for (int i = 0; i < n; i++)
delete[] P1[i];
delete[] P1;
for (int i = 0; i < m; i++)
delete[] P2[i];
delete[] P2;
for (int i = 0; i < n; i++)
delete[] P3 [i];
delete[] P3;
system("pause");
return 0;
}
1 / 1 / 4
Регистрация: 01.10.2016
Сообщений: 247
1
15.06.2017, 20:47. Показов 68977. Ответов 1
Добрый день, при написании кода я столкнулся с проблемой, cout везде выбивает «
«cout» не является однозначным С++», как решить эту проблему?
Условие : «С помощью перегруженных функций реализуем задачу для различных типов массивов, например для типов int и float. «
Код:
| C++ | ||
|
__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь
0
- Forum
- General C++ Programming
- Cout is ambiguous?
Cout is ambiguous?
What does that mean? How do I fix it?
Post the actual error message, as well as the line of code which is causing the error.
Post your code so that it is [code]between code tags[/code] as this will give it syntax highlighting and line numbers.
Please copy and paste the exact error message, and indicate which line the error is talking about.
Last edited on
Well, I am working on this bank database project and whenever I post this part:
void addaccount()
{
ifstream inData;
ofstream outData;
string fileName;
string str;
cout << «Insert the name of the data file: «;
cin >> fileName;
inData.open(fileName); // Access the file of the name you had inputted
string lastName, firstName, type;
double balance;
inData >> lastName >> firstName >> balance >> type;
cout << «What file would you like to save the data in?: «;
cin >> fileName;
outData.open(fileName);
outData << str;
cout << «nEnter the customer’s last name:»;
cin >> lastName;
cout << «nnEnter the customer’s first name : «;
cin >> firstName;
cin.ignore();
cin.getline(50, firstName);
cout << «nEnter Type of The account (C/S) : «;
cin >> type;
type = toupper(type);
cout << «nEnter The Initial amount(>=500 for Saving and >=1000 for current ) : «;
cin >> deposit;
cout << «nnnAccount Created.»;
}
void deleteaccount();
{
account ac;
ifstream inFile;
ofstream outFile;
inFile.open(«account.dat», ios::binary);
if (!inFile)
{
cout << «File could not be open !! Press any Key…»;
return;
}
outFile.open(«Temp.dat», ios::binary);
inFile.seekg(0, ios::beg);
while (inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
{
if (ac.retacno() != n)
{
outFile.write(reinterpret_cast<char *> (&ac), sizeof(account));
}
}
inFile.close();
outFile.close();
remove(«account.txt»);
rename(«Temp.txt», «account.txt»);
cout << «nntRecord Deleted ..»;
}
void search();
{
int seqSearch(const int list[], int listLength, int searchItem)
{
int loc;
bool found = false;
for (loc = 0; loc < listLength; loc++)
if (list[loc] == searchItem)
{
found = true;
break;
}
if (found)
return loc;
else
return -1;
}
into it, all the couts get the error message IntelliSense: «cout» is ambiguous.
Speaking of which, I really need help with that. I have a topic called ‘Bank Database’ I could really use help with.
IntelliSense errors aren’t compilation errors. Sometimes IntelliSense can get confused or out of date.
Go to Build -> Rebuild
You may also consider trying to prefix your ‘cout’ object with its namespace, ‘std’. In other words, wherever you’ve put
cout << "Information";
You may consider putting
std::cout << "Information";
Perhaps there are multiple objects called ‘cout’ in your program (or you’ve included external libraries which also have a cout object) and providing a namespace might give some clarification as to which one you mean.
Topic archived. No new replies allowed.
