声明一个一维数组对象
声明并实现一个类CArray表示一个一维数组对象。该对象具有的行为:(1)获得指定下标的数组元素;(2)设置指定下标的数组元素;(3)输出所有元素的值。(4)其他你认为具备的行为。高手来帮忙做啊,我不会啊~~~
谢谢了,嘿嘿~~
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[];
} 你看看string类吧 那里不对能否指出来啊
谢谢了 我是让楼主看看..你的进步很快了..呵呵,不是说你 写代码的时候总不是很自信
代码肯定有不足之处
不知道写的对不对 那就写写啊..呵呵,实在不行,看看java里面的数组模板也好... java里面的数组模板 不知道在C++里面有没有用 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 不好意思 看不懂 也就是几个函数原形..都是msdn上的 哦 需要看的东西还有很多
页:
[1]
