I have a class Customer I create a CustomerFactory for it but I would also like to include a Customer_Mock. So I think my factory will create a customer_mock instead of a real customer. Here is what I have done. But I am kept reminded of link error *.ctor as unresolved token and unresolved external symbol*. I am wrong about something I don't have an idea how to fix it myself. Thank you
PHP Code:
using namespace System;
ref class Customer
{
int age;
String^ Name;
public:
Customer();
Customer(int a, String^ n)
{
Name=n;age=a;
}
virtual void Func()
{
Console::WriteLine(L"Customer Func");
}
};
ref class Customer_Mock:Customer
{
int age;
String^ Name;
public:
Customer_Mock( int age,String^name){this->age=age;this->Name=name;}
virtual void Func() override
{
Console::WriteLine(L"Mock is called");
}
};
ref class CustomerFactory
{
CustomerFactory(){Console::WriteLine(L"Customer Factory Constructor");}
public:
static Customer_Mock^ CreateCustomer(int age,String^name )
{
return gcnew Customer_Mock(age,name);
}
};
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
Customer^c=CustomerFactory::CreateCustomer(10,L"simpson");
c->Func();
return 0;
}