Answer the question
In order to leave comments, you need to log in
Error with c++ vector?
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
struct Customer
{
int customerID;
std::string salutation;
std::string dateOfBirth;
std::string state;
std::string creationDate;
};
struct Item
{
int itemID;
std::string size;
std::string color;
int manufacturerID;
double price;
};
struct Order
{
int orderItemID;
std::string orderDate;
std::string deliveryDate;
Customer *customer;
Item *item;
};
int main()
{
std::string str;
std::ifstream file("C:\\Users\\User\\Desktop\\инт сис\\04\\orders_class.txt", std::ios::in);
std::vector<Order>*vec = new std::vector<Order>();
while (!file.eof())
{
getline(file, str);
//std::cout << str << std::endl;
vec->push_back(new std::vector<Order>());
};
file.close();
system("pause");
return 0;
}
ошибка там где vec->push_back(new std::vector<Order>());
Серьезность Код Описание Проект Файл Строка Состояние подавления
Ошибка C2664 "void std::vector<Order,std::allocator<_Ty>>::push_back(const Order &)": невозможно преобразовать аргумент 1 из "std::vector<Order,std::allocator<_Ty>> *" в "Order &&" analytics c:\users\user\documents\visual studio 2015\projects\main.cpp 39
Answer the question
In order to leave comments, you need to log in
Decided like this:
std::vector<Order*>*vec = new std::vector<Order*>();
vec->push_back(new Order());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question