class two;
class one
{
int a;
public:
one()
{
a = 8;
}
friend two;
};
class two
{
public:
two() { }
two(one i)
{
cout << i.a;
}
};
int main()
{
one o;
two t(o);
getch();
}
Run Code Online (Sandbox Code Playgroud)
我从Dev-C++得到这个错误:
a class-key must be used when declaring a friend
Run Code Online (Sandbox Code Playgroud)
但是使用Microsoft Visual C++编译器编译时运行正常.
我的程序返回内存错误,而不使用超过1 MB.我在dev-cpp编译器中编写C语言.原来的程序太大了,无法放在这里.这个非常简单的程序适合我:
int main(){int a[520076]; return 0;}
并返回值0.但是,这个:
int main(){int a[520077]; return 0;}
不起作用,原因是记忆.我使用的是Windows 8,但Windows 7中出现了同样的问题.看起来系统对进程可以使用的内存空间进行了限制.也许dev-cpp还可以建立边界吗?
我正在研究一个石头剪刀程序,但这次计算机选择摇滚一半时间,剪刀三分之一时间,纸张只有六分之一时间.我这样做的方式是我列举了六种可能的计算机选择值:
enum choicec {rock1, rock2, rock3, scissors1, scissors2, paper};
choicec computer;
Run Code Online (Sandbox Code Playgroud)
但是,在计算机做出选择之后,我必须将这些枚举值转换为摇滚,纸张或剪刀.我使用switch-case语句做到了这一点:
switch(computer) {
case rock1 || rock2 || rock3:
c = 1;
break;
case scissors1 || scissors2: //ERROR!
c = 3;
break;
case paper:
c = 2;
break;
}
Run Code Online (Sandbox Code Playgroud)
一个是摇滚,两个是纸,三个是剪刀.但是,在我作为注释写入错误的行上,它给了我这个错误:[错误]重复的案例值.
我不知道为什么.有任何想法吗?
我正在读Ivor Horton的Beginning C. 无论如何我无限期地for打印我的printf声明两次,然后再继续.我确定我做错了但是我从书中复制了代码.如果重要的话,我正在使用Dev-C++.这是代码......谢谢
#include <stdio.h>
#include <ctype.h> // For tolower() function //
int main(void)
{
char answer = 'N';
double total = 0.0; // Total of values entered //
double value = 0.0; // Value entered //
int count = 0;
printf("This program calculates the average of"
" any number of values.");
for( ;; )
{
printf("\nEnter a value: ");
scanf("%lf", &value);
total+=value;
++count;
printf("Do you want to enter another value? (Y or N): "); …Run Code Online (Sandbox Code Playgroud) 我正在使用Dev-C++编译器.这个程序应该打印30但是它的打印384.
#include <stdio.h>
int main() {
int n = 3;
int ans;
ans = n<<3 + n<<1;
printf("%d", ans);
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud) 最后我从开始菜单运行MinGW-w64 Win32 Shell并分别运行以下命令:
吃豆人-Sy吃豆人
吃豆人
吃豆人
在PATH中添加C:\ msys32 \ mingw32 \ bin。
我的问题:
提前致谢。
所以我试图像往常一样测试运行我的dev c ++并且它说无法执行location/name.exe错误193:%1不是有效的win 32应用程序.我还没有将编译器用于任何复杂的事情.
#include<stdio.h>
#include<math.h>
#define PI 3.14
int main()
{
int r = 3;
float area = PI*pow(r,2);
printf("the area of the circle is %f",area);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Dev c ++ GCC(MinGW)编译器.
它编译正确,但当我尝试运行时,它会收到此错误消息
无法执行"C:\ Users\SIM JONES NIGL TD\Desktop\c language\areaofcircle2.exe":错误193:%1不是有效的Win32应用程序.
按任意键继续
这是我编写的代码,用于查看auto关键字如何工作,但它没有在 Dev C++ 中编译并给出以下警告:
[警告] C++11 auto only available with -std=c++11 or -std=gnu ++11
如何克服这个故障并按照警告的指示去做?
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
std::vector<auto> v={2,-1,4,6,7};
auto beg = v.begin();
while (beg != v.end())
{
++beg;
cout<<beg;
}
}
Run Code Online (Sandbox Code Playgroud) 我已经制作了一个关于此的程序,该程序使用Dev C++CPP创建了很多文件,这个程序也使用 Dev C++ 但现在它显示错误。我的专业是创建模板,但它显示.codeHTMLerror
这是我的一些code:
#include <iostream>
using std::cout;
using std::cin;
using std::ofstream;
using std::endl;
void HelloWorld() {
ofstream outfile ("html1.html");
outfile << "<html> " << endl;
outfile << " <head> <title> Template Hello World </title> </head>" << endl;
outfile << " <body> <h1> Hello World! </h1> </body> " << endl;
outfile << "</html> " << endl;
outfile << "// Template HTML 2018 " << endl;
cout << "Created Succesfuly! Directory: …Run Code Online (Sandbox Code Playgroud) 我正在尝试读取数据并解决简单问题,数据:
3 - number of lines to read in
1 1
2 2 2
3 4
Run Code Online (Sandbox Code Playgroud)
在输入每一行之后,我想获得输入数量的总和,但每行中的整数数量是未知的.使用上面的数据后,屏幕应如下所示:
3
1 1
Sum: 2
2 2 2
Sum: 6
3 4
Sum: 7
Run Code Online (Sandbox Code Playgroud)
但是根据我的算法,我得到了输出:
3
1 1
Sum: 1
2 2 2
Sum: 4
3 4
Sum: 3
Run Code Online (Sandbox Code Playgroud)
我已经写代码,但它不能正常工作(如上):
版
我提高了我的代码,并知道它正常工作,不附带任何条件等,适当的代码如下:
#include<iostream>
using namespace std;
int main()
{
int x;
int t, sum;
cin >> t;
for(int i=0; i<t; i++) {
sum=0;
while(true)
{
cin >> x;
sum = sum + x; …Run Code Online (Sandbox Code Playgroud)