Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++之Function傳遞array參數

0 views
Skip to first unread message

lees

unread,
Jul 23, 1997, 3:00:00 AM7/23/97
to

==> 在 kalaen@cis_nctu (指揮到天亮) 的文章中提到:
> 我有一class A之menber function要回傳一array
> 給另一個class B中的menber function用
> 怎麼傳會比較好?
> 在VC++中
> 用POINTER好像不行
> 雖然COMPILE會過
> 可是實際上使用會有記憶體使用錯誤


Class A {
public:
char *getPtr(){ return s; }
A( char *p) { strcpy( s, p ); }
private:
char s[10];
};

class B {
public:
printCharArray( char * p )
{
cout << p;
}
};

void main()
{

A a( "abc" );
B b;

b.printCharArray( a.getPtr());

}

--
* Origin: ★ 交通大學資訊科學系 BBS ★ <bbs.cis.nctu.edu.tw: 140.113.23.3>

0 new messages