所以这是我的程序的一部分,我无法调用函数,我真的需要一些帮助.它基本上是选择任一功能并输入数据,然后打印该数据.我做错了什么?请帮助,我一直在努力
"[链接器]引用
Customer_Record()'" , [Linker error] undefined reference toCar_Record()'和'ld返回1退出状态"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
void Customer_Record(), Car_Record();
int num;
struct Customer {
char customer_ID[20];
int license;
char address[20];
int phone;
char email[20];
} cust;
struct car {
int regno[20];
char model[20];
char colour[10];
} car;
main() {
printf(" Enter 1 to go to Customer Record \n\n");
printf(" Enter 2 to go to Car Record \n\n");
scanf("%d", &num);
if (num = 1) {
Customer_Record(); …Run Code Online (Sandbox Code Playgroud) class A {};
class B : private A {
};
class C : public B {
public:
void f() {
A a; // This line causes error, but works when it is in main() function
}
};
int main()
{
C c;
// A a; --> This line works
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我猜这与B私人继承有关,A但不能把我的手指放在上面.
编辑:错误是"A类不可见".用g ++编译.
我正在开发gsoap web服务,我正在检索对象的向量以回复查询.我有两种方法可以做到:首先是简单循环和迭代器.他们都没有工作.
错误是:
错误:不匹配
'operator<<'in'std::cout mPer.MultiplePersons::info.std::vector<_Tp, _Alloc>::at<PersonInfo, std::allocator<PersonInfo> >(((std::vector<PersonInfo>::size_type)i))'
MultiplePersons mPer; // Multiple Person is a class, containing vector<PersonInfo> info
std::vector<PersonInfo>info; // PersonInfo is class having attributes Name, sex, etc.
std::vector<PersonInfo>::iterator it;
cout << "First Name: \t";
cin >> firstname;
if (p.idenGetFirstName(firstname, &mPer) == SOAP_OK) {
// for (int i = 0; i < mPer.info.size(); i++) {
// cout << mPer.info.at(i); //Error
//}
for (it = info.begin(); it != info.end(); ++it) {
cout << *it; // Error
} …Run Code Online (Sandbox Code Playgroud) 4EVER
我知道这个标识符是无效的,因为它以一个在matlab中不允许的数字开头.
我的问题是如何编写matlab代码来检查它是否有效?
我在大学里用C++做作业,有一条我根本无法理解的路线:
cout << fixed << setprecision( 2 );
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解释这一行吗?
为什么我的大小为1 my_game.size()?我认为make_game将插入的参数将被插入game,因此arguments.length将是3,但显然它不是.这是什么原因?
function game()
{
var args = arguments;
this.size = function() { return args.length; };
}
function make_game()
{
return new game(arguments);
}
var my_game = make_game(4, 'a', true);
console.log(my_game.size()); // 1
Run Code Online (Sandbox Code Playgroud) 有这个功能.
var cache = [];
$.preLoadImages = function() {
var args_len = arguments.length;
for (var i = args_len; i--;) {
var cacheImage = document.createElement('img');
cacheImage.src = arguments[i];
cache.push(cacheImage); console.log(i)
}
}
Run Code Online (Sandbox Code Playgroud)
然后你就可以这样称呼它
$.preLoadImages("image1.png", "image2.png", "image3.png");
Run Code Online (Sandbox Code Playgroud)
我需要在变量中存储多个图像URL,然后将其传递给函数.
"arguments"类型是Object,所以我处理了一个对象或数组,但它不起作用.
你对如何将urls集合传递给该函数有任何想法吗?
我有这个char*:
char* line = "This is a great day";
string subLine;
Run Code Online (Sandbox Code Playgroud)
我想要subLine包括:is a great
(从地方5复制,接下来的10个字符).
有没有办法做到这一点,而不是转换char*为std::string?
我刚刚开始使用C++并且有一些C#的经验,所以我总体上有一些编程经验.然而,似乎马上就被击落了.我试过在Google上寻找,以免浪费任何人的时间无济于事.
int main(int argc, char *argv[])
{
HANDLE hConsole;
int k = 5;
string h;
string password = "pass";
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, k);
SetConsoleTextAttribute( GetStdHandle( STD_INPUT_HANDLE ), 0x5B );
while (h != password)
{
printf("This PC is locked\nEnter the password to gain access\n");
scanf("%s", &h);
}
printf("\n");
system("PAUSE");
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
每当我运行它,它将让我输入密码,当我点击输入它将确认然后崩溃要求我调试或发送信息给微软.当我添加while循环检查两个字符串时,这开始了.我是否正确地执行了此操作或者我错过了什么?
以防万一不清楚.我希望程序将字符串与输入进行比较,如果它们都相同,则程序将结束.
谢谢你的期待.
我有一个具有此功能的"Fan"类:
string getName();
Run Code Online (Sandbox Code Playgroud)
我想在课外的另一个函数中使用它:
string print(const Fan& fan) {
std::stringstream ss;
ss << "Fan : " << fan.getName() ;
return ss.str();
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
..\mtm_ex4.cpp:37:52:错误:传递丢弃限定符的
'const mtm::Fan''this'参数'std::string mtm::Fan::getName()'[-fpermissive]
这是为什么?!
更新:
当我将其更改为:
string getName() const;
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
未定义的引用
mtm::Fan::getName() const