想关联两个函数,可是编译时出现pr渲染时错误编译影片求解答!(以下代码)

> 问题详情
下列说法正确的是()。 A.内联函数在运行时将该函数的目标代码插入每个调用该函数的地方B.内联函
悬赏:0&答案豆
提问人:匿名网友
发布时间:
下列说法正确的是()。A.内联函数在运行时将该函数的目标代码插入每个调用该函数的地方B.内联函数在编译时将该函数的目标代码插入每个调用该函数的地方C.类的内联函数必须在类体内定义D.类的内联函数必须在类体外通过加关键字inline定义请帮忙给出正确答案和分析,谢谢!
为您推荐的考试题库
您可能感兴趣的试题
1有下列程序:#include&stdi0.h&voidmain(  ){FILE*pf;char*s1="China",*s2="Beijing";pf=fopen("abc.dat","wb+");fwrite(s2,7,1,pf);rewind(pf);/*文件位置指针回到文件开头*/fwrite(s1,5,1,pf);fclose(pf);}以上程序执行后abc.dat文件的内容是(  )。A.ChinaB.ChinangC.ChinaBeijingD.BeijingChina2下列叙述中正确的是(  )。A.在面向对象的程序设计中,各个对象之间具有密切的关系B.在面向对象的程序设计中,各个对象都是公用的C.在面向对象的程序设计中,各个对象之间相对独立,相互依赖性小D.上述三种说法都不对3设有定义语句int(*f)(int);,则下列叙述正确的是(  )。A.f是基类型为int的指针变量B.f是指向函数的指针变量,该函数具有一个int类型的形态C.f是指向int类型一维数组的指针变量D.f是函数名,该函数的返回值是其类型为int类型的地址4为类Matrix重载下列运算符号时,只能作为Matrix类成员函数重载的运算符是(  )。A.+B.=C.&&D.++
我有更好的答案
请先输入下方的验证码查看最佳答案
图形验证:
验证码提交中……
找答案会员
享三项特权
找答案会员
享三项特权
找答案会员
享三项特权
选择支付方式:
支付宝付款
郑重提醒:支付后,系统自动为您完成注册
请使用微信扫码支付(元)
支付后,系统自动为您完成注册
遇到问题请联系在线客服QQ:
请您不要关闭此页面,支付完成后点击支付完成按钮
遇到问题请联系在线客服QQ:
恭喜您!升级VIP会员成功
常用邮箱:
用于找回密码
确认密码:在 SegmentFault,解决技术问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
一线的工程师、著名开源项目的作者们,都在这里:
获取验证码
已有账号?
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
c代码如下(环境vs2015)
#include&stdio.h&
#include&stdlib.h&
#include&stdarg.h&
void show_arry(const double ar[], int n);
double * new_d_array(int n, ...);
int main()
double *p1;
double *p2;
p1 = new_d_array(5, 1.2, 2.3, 3.4, 4.5, 5.6);
p2 = new_d_array(4, 100.0, 20.0, 8.08, -1890.0);
show_arry(p1, 5);
show_arry(p2, 4);
double * new_d_array(int n, ...)
p = (double*)malloc(n * sizeof(double));
va_start(ap, n);
for (int i = 0; i & i++)
*p++ = va_arg(ap, double);
va_end(ap);
void show_arry(const double ar[], int n)
for (int i = 0; i & i++)
printf("%4.2f ", ar[i]);
puts("\n");
以上代码运行出现错误,打印0.00 -0.00 0.00 0.00 0.000.00 0.00 0.00 0.00并报错 。将函数double * new_d_array(int n, ...)内
for (int i = 0; i & i++)
*p++ = va_arg(ap, double);
中的*p++改为p[i]运行正确。请问是出现了什么问题?
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
错误应该出现在第16行,invalid pointer。简单说,错误不在*p++,而是在第31行。问题在于你reutrn的不是malloc返回的p 而是p+5。打印0.00 -0.00 0.00 0.00 0.00是因为第14行 show_arry(p1, 5);传的p1 实际是 p+5 不是p。然后第16行free的时候丢error,因为free 的是p+5 不是malloc 返回的p。
p[i]运行正确是因为返回的p是malloc 返回的p,p的值没有改变。
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
此答案已被屏蔽
同步到新浪微博
分享到微博?
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:主题 : 编译出错Xcode提示不允许是用id类型传递在C函数中,求解答
级别: 新手上路
可可豆: 44 CB
威望: 46 点
在线时间: 41(时)
发自: Web Page
编译出错Xcode提示不允许是用id类型传递在C函数中,求解答&&&
// --------------------------------------------------
// constants for the different kinds of shapes and their colors
typedef enum {
kRedColor,
kGreenColor,
kBlueColor
} ShapeC
// --------------------------------------------------
// Shape bounding rectangle
typedef struct {
int x, y, width,
} ShapeR
// --------------------------------------------------
// convert from the ShapeColor enum value to a human-readable name
NSString *colorName (ShapeColor color)
{
NSString *colorN
switch (color) {
case kRedColor:
colorName = @"red";
case kGreenColor:
colorName = @"green";
case kBlueColor:
colorName = @"blue";
colorName = @"oops! Unexpected color";
return (colorName);
} // colorName
// --------------------------------------------------
// Shapes base class
@interface Shape : NSObject
{
ShapeColor& fillC
ShapeRect &
}
- (void) setFillColor: (ShapeColor) fillC
- (void) setBounds: (ShapeRect)
- (void)
@end // Shape
@implementation Shape
- (void) setFillColor: (ShapeColor) c
{
fillColor =
} // setFillColor
- (void) setBounds: (ShapeRect) b
{
bounds =
} // setBounds
- (void) draw
{
} // draw
@end // Shape
// --------------------------------------------------
// All about Triangles
@interface Triangle : Shape
@end // Triangle
@implementation Triangle
- (void) draw
{
NSLog (@"drawing a triangle at (%d %d %d %d) in %@",
& bounds.x, bounds.y,
& bounds.width, bounds.height,
& colorName(fillColor));
} // draw
@end // Triangle
// --------------------------------------------------
// All about Circles
@interface Circle : Shape
@end // Circle
@implementation Circle
- (void) draw
{
NSLog (@"drawing a circle at (%d %d %d %d) in %@",
& bounds.x, bounds.y,
& bounds.width, bounds.height,
& colorName(fillColor));
} // draw
@end // Circle
// --------------------------------------------------
// All about Rectangles
@interface Rectangle : Shape
@end // Rectangle
@implementation Rectangle
- (void) draw
{
NSLog (@"drawing a rectangle at (%d %d %d %d) in %@",
& bounds.x, bounds.y,
& bounds.width, bounds.height,
& colorName(fillColor));
} // draw
@end // Rectangle
// --------------------------------------------------
// All about OblateSphereoids
@interface OblateSphereoid : Shape
@end // OblateSphereoid
@implementation OblateSphereoid
- (void) draw
{
NSLog (@"drawing an egg at (%d %d %d %d) in %@",
& bounds.x, bounds.y,
& bounds.width, bounds.height,
& colorName(fillColor));
} // draw
@end // OblateSphereoid
// --------------------------------------------------
// Draw the shapes
void drawShapes (id shapes[], int count)
{
for (int i = 0; i & i++)
& & {
id shape = shapes;
[shape draw];
} // drawShapes
// --------------------------------------------------
// The main function.& Make the shapes and draw them
int main (int argc, const char * argv[])
{
id shapes[4]; // I'm different!
ShapeRect rect0 = { 0, 0, 10, 30 };
shapes[0] = [Circle new];
[shapes[0] setBounds: rect0];
[shapes[0] setFillColor: kRedColor];
ShapeRect rect1 = { 30, 40, 50, 60 };
shapes[1] = [Rectangle new];
[shapes[1] setBounds: rect1];
[shapes[1] setFillColor: kGreenColor];
ShapeRect rect2 = { 15, 19, 37, 29 };
shapes[2] = [OblateSphereoid new];
[shapes[2] setBounds: rect2];
[shapes[2] setFillColor: kBlueColor];
ShapeRect rect3 = { 47, 32, 80, 50 }; // I'm new!
shapes[3] = [Triangle new];
[shapes[3] setBounds: rect3];
[shapes[3] setFillColor: kRedColor];
drawShapes (shapes, 4); // I'm different!
return (0);
这处代码是《Objective-c基础教程》的原本代码。打开书中提供的源代码项目 是可以编译运行的。但是我自建项目粘贴代码缺会提示错误,错误如下
1.Must explicitly describe intended ownership of an object array parameter
2.Passing '__strong id *' to parameter of type '__unsafe_unretained id *' changes retain/release properties of pointer
我不太明白为什么会出现这样的错误?为何源代码提供的项目不出错呢?求大虾解答?
附图如下:
可可豆: * CB
威望: * 点
在线时间: (时)
注册时间: *
最后登录: *
发自: Web Page
不知道你找到答案没有,问题的原因是老版本软件的ARC兼容性问题,需要把编译选项&Automatic Reference Counting Issue& 设为“NO“。
这个链接给出了答案:http://blog.csdn.net/wbw1985/article/details/7644815
级别: 新手上路
可可豆: 44 CB
威望: 46 点
在线时间: 41(时)
发自: Web Page
感谢。我其实已经知道这个问题了谢谢
关注本帖(如果有新回复会站内信通知您)
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 关注CVP公众号
扫一扫 浏览移动版

我要回帖

更多关于 调用js函数时发生错误 的文章

 

随机推荐