| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 640 人关注过本帖
标题:which way is standard C++?
取消只看楼主 加入收藏
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
 问题点数:0 回复次数:2 
which way is standard C++?

/*---------------------------------------------------------------------------
File name: stdc++.cpp
Author: HJin (email: fish_sea_bird [at] yahoo [dot] com )
Created on: 8/29/2007 15:51:23
Environment: Windows XP Professional SP2 English +
Visual Studio 2005 v8.0.50727.762

Following C++ source code compiles under VC 2005. It won't compile under g++.

Your task is to select the delcarations which are conformant to standard C++.

*/

#include <iostream>
using namespace std;

class A
{
public:
A(int i_=0) : i(i_)
{
}

private:
int i;
};

int main()
{
// which way is standard C++?

A* pA1 = new A; // A
A* pA2 = new A(); // B
A* pA3 = new A[5](); // C
A* pA4 = new A[5]; // D

return 0;
}

[此贴子已经被作者于2007-8-30 6:51:52编辑过]

搜索更多相关主题的帖子: standard 
2007-08-30 06:48
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
AD?

Think a little bit more. Or refer to Stroustrup's book.

I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-08-30 12:01
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
I voted B and D, although A will be accepted by most compliers.

C is okay for VC, but not for g++.

I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-08-30 12:53
快速回复:which way is standard C++?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.038195 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved