검색결과 리스트
default에 해당되는 글 1건
- 2016.04.25 [C++] 틀린 default 지정
shop.h
#include <string>
#include <vector>
#include <memory>
#include <fstream>
class Item
{
};
class Shop
{
public:
Shop() {}
Shop(std::string name, std::initializer_list<std::shared_ptr<Item>> items) {}
Shop(std::string name, std::string fileName) {}
void ReadDataFromFile() {}
Shop(const Shop &) = default;
Shop& operator=(const Shop&) = default;
//Shop(Shop&& shop) = default;
//Shop& operator=(Shop&& other) = default;
~Shop() {};
void ShowItemList() {}
private:
std::string m_name;
std::vector<std::shared_ptr<Item>> m_items;
std::string m_fileName;
std::ifstream m_fileStream;
};
main.cpp
int main()
{
Shop weaponArmorShop = Shop("Weapon/Armor Shop", "equip_item.txt");
//Shop temp1("Weapon/Armor Shop", "equip_item.txt");
//Shop weaponArmorShop(temp1);
//Shop weaponArmorShop2 = temp1;
return 0;
}
위 코드를 실행하면 아래와 같은 에러가 나온다
왜 이런 에러가 나올까? 코드를 유심히 보고, default에 대한 정확하게 안다면 어렵지 않다.
나는 default에 대해서 자세히까지는 몰라서 잠깐이지만 당황했음 ^^;
댓글