搜索
编程论坛
→
开发语言
→
C++论坛
→
『 C++教室 』
→ 线性表的动态存储
标题:
线性表的动态存储
只看楼主
zfeidy
等 级:
新手上路
帖 子:33
专家分:0
注 册:2007-3-26
楼主
问题点数:0 回复次数:2
线性表的动态存储
#include<iostream>
const int MaxSize=1000;
using namespace std;
class CircList
{
public:
CircList();
void fun(int data[],int n,int m);
private:
int data[MaxSize];
int n;
int m;
};
怎么在类中实现线性表的动态存储啊?
即把上面的MaxSize作为一个动态值.
搜索更多相关主题的帖子:
线性
动态
2007-06-12 21:19
herbert_1987
等 级:
贵宾
威 望:
15
帖 子:1314
专家分:0
注 册:2007-5-13
第
2
楼
得分:0
可以加一个增量呀:
#define INCREASE 10
data 不用数组, 改成指针
int *data;
初始化的时候给data分配MaxSize 个空间,
不够空间的时候给 data添加 INCREASE 个空间
人生重要的不是所站的位置,而是所朝的方向
2007-06-14 01:13
HJin
等 级:
贵宾
威 望:
27
帖 子:401
专家分:0
注 册:2007-6-9
第
3
楼
得分:0
if you want to make your list grow dynamically, you have to use dynamic memory allocation.
int data[MaxSize]; // this is static memeory allocation
In C++, you may use new and delete to to manage it; in C, you use malloc/realloc and free to magage it.
I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-06-14 02:29
3
1/1页
1
参与讨论请移步原网站贴子:
https://bbs.bccn.net/thread-146906-1-1.html
关于我们
|
广告合作
|
编程中国
|
清除Cookies
|
TOP
|
手机版
编程中国
版权所有,并保留所有权利。
Powered by
Discuz
, Processed in 0.078235 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved