const  & Pointer

const char *const * keywords

const char const * keywords

const char *const  keywords

const char const keywords

请问以上四种定义,
所得出的变量有什么区别,各代表什么?(请从维数、用途等方面简要说明) 
 

 

 

1. ( (const char) *const) * keywords //指针,前面是指针指向的类型

2. (const char const) * keywords //指针,前面是指针指向的类型

3. (const char) *const  keywords //常量指针,前面是指针指向的类型

4. (const char const) keywords //常量,char前后的const都一样

看的时候,4 3 2 1 一个一个的分析就明白了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码运行时显示munmap_chunk(): invalid pointer,应该怎么修改?#include<iostream> #include<string> using namespace std; class Creature { public: Creature(const int& hands, const int& legs):_hands(hands),_legs(legs) {cout << "A Creature has been created!" << endl; cout << "It has " << hands << " hand(s)!" << endl; cout << "It has " << legs << " leg(s)!" << endl;} ~Creature() {cout << "Creature object exiled!" << endl;} int GetHands() const {return _hands;} int GetLegs() const {return _legs;} private: int _hands; int _legs; }; class Beast:virtual public Creature { public: Beast(const int& hands, const int& legs, const string& name) :Creature(hands,legs),_name(name){cout << "Its beast name is " << _name << endl;} ~Beast() {cout << "Beast object exiled!" << endl;} string GetName() const {return _name;} private: string _name; }; class Human:virtual public Creature { public: Human(const int& hands, const int& legs, const string& name):Creature(hands,legs),_name(name) {cout << "Its human name is " << _name << endl;} ~Human() {cout << "Human object exiled!" << endl;} string GetName() const {return _name;} private: string _name; }; class Orc:public Human,public Beast { public: Orc(const int& hands, const int& legs, const string& beast_name, const string& human_name):Creature(hands, legs),Beast(hands,legs,beast_name),Human(hands,legs,human_name){} ~Orc() {cout << "Orc object exiled!" << endl;} string GetBeastName() const {return Beast::GetName();} string GetHumanName() const {return Human::GetName();} };
05-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值