| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2242 人关注过本帖
标题:声明一个一维数组对象
只看楼主 加入收藏
zxl20081024
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-4-29
收藏
 问题点数:0 回复次数:11 
声明一个一维数组对象
声明并实现一个类CArray表示一个一维数组对象。该对象具有的行为:(1)获得指定下标的数组元素;(2)设置指定下标的数组元素;(3)输出所有元素的值。(4)其他你认为具备的行为。
高手来帮忙做啊,我不会啊~~~
谢谢了,嘿嘿~~
搜索更多相关主题的帖子: 声明 对象 元素 标的 行为 
2008-04-29 19:23
newyj
Rank: 2
等 级:新手上路
威 望:3
帖 子:542
专家分:0
注 册:2008-1-4
收藏
得分:0 
新手不知道对不对
class CArray{
  public:
    CArray(const std::string& str){a[]=str;};
    CArray(const CArray& var){a[]=var.a;};
    ~CArray(){};
    void getstr()const{cout<<a;};
    int getvalue()const{return sizeof a/sizeof a[0];};
    const char getnumber(const int m)const{return a[m];};
  private:
    char a[];  
}
2008-04-29 21:10
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
你看看string类吧

学习需要安静。。海盗要重新来过。。
2008-04-29 21:21
newyj
Rank: 2
等 级:新手上路
威 望:3
帖 子:542
专家分:0
注 册:2008-1-4
收藏
得分:0 
那里不对能否指出来啊
谢谢了
2008-04-29 21:27
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
我是让楼主看看..你的进步很快了..呵呵,不是说你

学习需要安静。。海盗要重新来过。。
2008-04-29 21:29
newyj
Rank: 2
等 级:新手上路
威 望:3
帖 子:542
专家分:0
注 册:2008-1-4
收藏
得分:0 
写代码的时候总不是很自信
代码肯定有不足之处
不知道写的对不对
2008-04-29 21:54
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
那就写写啊..呵呵,实在不行,看看java里面的数组模板也好...

学习需要安静。。海盗要重新来过。。
2008-04-29 22:05
newyj
Rank: 2
等 级:新手上路
威 望:3
帖 子:542
专家分:0
注 册:2008-1-4
收藏
得分:0 
java里面的数组模板 不知道在C++里面有没有用
2008-04-29 22:07
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
c++里面也有...
CArray Class Members
Construction

CArray Constructs an empty array.


Attributes

GetSize Gets the number of elements in this array.
GetUpperBound Returns the largest valid index.
SetSize Sets the number of elements to be contained in this array.


Operations

FreeExtra Frees all unused memory above the current upper bound.
RemoveAll Removes all the elements from this array.


Element Access

GetAt Returns the value at a given index.
SetAt Sets the value for a given index; array not allowed to grow.
ElementAt Returns a temporary reference to the element pointer within the array.
GetData Allows access to elements in the array. Can be NULL.


Growing the Array

SetAtGrow Sets the value for a given index; grows the array if necessary.
Add Adds an element to the end of the array; grows the array if necessary.
Append Appends another array to the array; grows the array if necessary
Copy Copies another array to the array; grows the array if necessary.


Insertion/Removal

InsertAt Inserts an element (or all the elements in another array) at a specified index.
RemoveAt Removes an element at a specific index.


Operators

operator [] Sets or gets the element at the specified index.


CArray Overview |  Base Class Members |  Hierarchy Chart

学习需要安静。。海盗要重新来过。。
2008-04-29 22:11
newyj
Rank: 2
等 级:新手上路
威 望:3
帖 子:542
专家分:0
注 册:2008-1-4
收藏
得分:0 
不好意思 看不懂
2008-04-29 22:14
快速回复:声明一个一维数组对象
数据加载中...
 
   



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

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