所以这是我的程序的一部分,我无法调用函数,我真的需要一些帮助.它基本上是选择任一功能并输入数据,然后打印该数据.我做错了什么?请帮助,我一直在努力
"[链接器]引用
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++ 11绑定表达式?例如,在下面的代码中,与结果相关联的绑定表达式f将首先将其参数乘以2,然后将结果加1:
#include <iostream>
#include <functional>
using namespace std::placeholders;
int main(int argc, char *argv[])
{
auto add1 = [](int x) { return x+1; };
auto mul2 = [](int x) { return x*2; };
auto f = std::bind(add1, std::bind(mul2, _1));
std::cout << f(0) << '\n';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我们可以创建一个转换版本,f而不是先添加一个,然后将结果乘以2; 结果表现得好像定义为:
auto f2 = std::bind(mul2, std::bind(add1, _1));
Run Code Online (Sandbox Code Playgroud)
这个例子的简化是因为它的结构类似于列表; 而绑定表达式通常是树.
我有以下代码.我试图消除将localization_data_t::language_t类型显式传递给lambda参数的需要.
auto language_itr = std::find_if(languages.begin(), languages.end(), [&](const localization_data_t::language_t& language)
{
return language.code == language_code;
});
Run Code Online (Sandbox Code Playgroud)
我假设有一种方法可以做到这一点,因为要迭代的对象的类型可以由编译器通过迭代器的底层类型派生.但是,我在旅行中没有找到这样的例子.
任何帮助,将不胜感激.
c++ ×7
c++11 ×2
javascript ×2
bind ×1
compile-time ×1
cout ×1
dev-c++ ×1
lambda ×1
matlab ×1
string ×1