我已经安装了Visual Studio 2013来尝试一些C ++代码来测试一个类的想法,这些类会将自己变成其他类和类似的东西(这是愚蠢的,但这个想法来自于梦想)并且它正在崩溃visual studio的编译器,不明白为什么。
只需编译它,一条标题为“Microsft C ++ Optimizer deixou de funcionar”的崩溃消息(停止以我的语言运行)
代码:
class F
{
public:
int f;
F(int f){ this->f = f; }
operator A(){ return A(f); }
operator P(){ return P(f); }
};
class A
{
public:
int a;
A(int a){ this->a = a; }
operator F(){ return F(a); }
operator P(){ return P(a); }
};
class P
{
public:
int p;
P(int p){ this->p = p; }
operator F(){ return F(p); }
operator A(){ return A(p); }
};
void stuff(F f)
{
printf("Val -> %d\n", f.f);
}
void main(int argc, char* argv[])
{
P p(3);
stuff((F)(A)(P)(F)(A)(P)(F)(A)p);
}
答案 0 :(得分:0)
试图用gcc构建它。没有崩溃,也没有建筑物...... 那是从不开始工作。如果想要解开你想要完成的事情,那就太晚了。这是错误消息:
||=== 001-forumQuestion, Release ===|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|11|error: expected type-specifier before 'A'|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|12|error: expected type-specifier before 'P'|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|23|error: expected type-specifier before 'P'|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|41|error: '::main' must return 'int'|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp||In function 'int main(int, char**)':|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|44|error: no matching function for call to 'P::P(F)'|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|44|note: candidates are:|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|31|note: P::P(int)|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|31|note: no known conversion for argument 1 from 'F' to 'int'|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|26|note: P::P(const P&)|
C:\Users\enhzflep\Documents\code\001-forumQuestion\main.cpp|26|note: no known conversion for argument 1 from 'F' to 'const P&'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|