| |

VerySource

 Forgot password?
 Register
Search
View: 1145|Reply: 10

Ask the master how to create a class object pointer array ??

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-23 20:20:01
| Show all posts |Read mode
I want to build an array of pointers of the Binarynode class to store the pointers of the class.
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-2-7 23:30:02
| Show all posts
Binarynode * p [10];
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-8 13:00:01
| Show all posts
I want to dynamically create an array of object pointers. How should I declare it?
Reply

Use magic Report

0

Threads

19

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-2-8 16:00:02
| Show all posts
Just direct new, why not use vector for dynamic?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-8 17:00:01
| Show all posts
Binarynode * p = new Binarynode [10];
Reply

Use magic Report

0

Threads

49

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-2-8 17:15:01
| Show all posts
typedef Binarynode * PBN;
PBN pointGroup [10];
PBN * pointGroup = new PBN [10];
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-9 10:15:01
| Show all posts
Binarynode * p = new Binarynode [10];
It looks like this is an array of classes, not an array of pointers. I just want to save the pointers. Thank you.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-9 21:45:01
| Show all posts
Binarynode * p = new (Binarynode *) [10];
No compile to try, but it should be.

It is also recommended to use std :: vector <Binarynode *> binarynodePointerVector;
Reply

Use magic Report

0

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-10 13:30:01
| Show all posts
typedef Binarynode * PBin;
PBin PVari [N]; or PBin PVari = new Binarynode [N];
Reply

Use magic Report

0

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-10 15:45:01
| Show all posts
typedef Binarynode * PBin;
PBin PVari [N]; or PBin * PVari = new (Binarynode *) [N];
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list