By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,134 Members | 1,742 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,134 IT Pros & Developers. It's quick & easy.

using classes with input of an array of char

P: 1
I'm trying to write a simple program that receives two doubles and one array of char that can be of lenght 9 or 10, and then introduces this input into a class. How do I have to define the array of char in the main program, the class and when I call the class?
Thanks
Andre
Jun 19 '06 #1
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
I would have thought

Expand|Select|Wrap|Line Numbers
  1. char data[10];
  2.  
  3. or possibly
  4.  
  5. unsigned char data[10];
  6.  
If you know that the array of data is going to be 9 or 10 bytes the difference is so little always define it as the maximum amount required. Of course you may also want to have a integer variablerecording how much data is used.
Jun 29 '06 #2

P: 1
All pointers, when passed as arguments, are reduced to pointer types, meaning using them as arguments are both messy and error prone. Thats why template classes, and the Standard library were created, to solve these messy situations. I recommend you read this.
Jul 2 '06 #3

Banfa
Expert Mod 5K+
P: 8,916
Hi Liam,

I assume you meant "All arrays" anyway I would say that using a vector to hold a small fixed length array was using a sledge hammer to crack a walnut (i.e. way over the top). A pointer or reference to an array is no less messy than a pointer or reference to a vector class.

Banfa
Jul 3 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.