#include<iostream>
using namespace std;
class shout
{
private:
char str[100];
public:
void sht(char[],int);
};
void sht(char str,int n)
{
int i;
for(i=1;i<=n;i++)
{
cout<<str<<endl;
}
}
void main()
{
shout sh;
cout<<"enter the string you want to dispaly:"<<endl;
char str[100];
cin.getline(str,100);
cout<<"enter the times you want to display for:"<<endl;
int n;
cin>>n;
sh.sht(str,n);
}
vs2010显示 错误 1 error LNK2019: 无法解析的外部符号 "public: void __thiscall shout::sht(char * const,int)" (?sht@shout@@QAEXQADH@Z),该符号在函数 _main 中被引用 G:\Visual studio solutions\CWS\CWS\MIAN.obj
错误 2 error LNK1120: 1 个无法解析的外部命令 G:\Visual studio solutions\CWS\Debug\CWS.exe 1
谁帮我看看这个C++小程序,有错误
答案:2 悬赏:20 手机版
解决时间 2021-04-28 09:48
- 提问者网友:世勋超人
- 2021-04-27 10:08
最佳答案
- 五星知识达人网友:执傲
- 2021-04-27 11:17
void shout::sht(char str,int n)
{
int i;
for(i=1;i<=n;i++)
{
cout<<str<<endl;
}
}
全部回答
- 1楼网友:行雁书
- 2021-04-27 12:44
#include <iostream> using namespace std;
class shout { private: char str[100]; public: void sht(char[],int); }; void shout::sht(char str[],int n)//作用域,得参数没匹配 { int i; for(i=1;i<=n;i++) { cout<<str<<endl; } }
void main() { shout sh; cout<<"enter the string you want to dispaly:"<<endl; char str[100]; cin.getline(str,100); cout<<"enter the times you want to display for:"<<endl; int n; cin>>n; sh.sht(str,n); }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯