473,322 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

using classes with input of an array of char

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
3 2936
Banfa
9,065 Expert Mod 8TB
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
Liam M
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
9,065 Expert Mod 8TB
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

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

Similar topics

6
by: hoover_richard | last post by:
I am a newbie to C++ and I need help with a simple program I am trying to write. My program is designed to print all of the odd integers contained in an array and output the sum of the odd...
7
by: Vaca Louca | last post by:
Hello, My setup: Debian sarge on dual Pentium 4. g++ 3.3.5-3. (the other system is Windows XP with MS Visual Studio .NET 2003) I have an auto_array<T> template (based on a template taken from...
12
by: BGP | last post by:
I am working on a WIN32 API app using devc++4992 that will accept Dow Jones/NASDAQ/etc. stock prices as input, parse them, and do things with it. The user can just cut and paste back prices into a...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
5
by: fakeprogress | last post by:
For a homework assignment in my Data Structures/C++ class, I have to create the interface and implementation for a class called Book, create objects within the class, and process transactions that...
7
by: fakeprogress | last post by:
For a homework assignment in my Data Structures/C++ class, I have to create the interface and implementation for a class called Book, create objects within the class, and process transactions that...
11
by: anto_kamau | last post by:
Question write a c program that displays a diamond pattern, when a user enters an odd number between 0 and 19, and displays on the screen
13
by: Superman859 | last post by:
Hello everyone. Heads up - c++ syntax is killing me. I do quite well in creating a Java program with very few syntax errors, but I get them all over the place in c++. The smallest little things...
9
by: gdarian216 | last post by:
I have written a c++ program that takes input from a file and outputs the average. The program uses structs and I need to convert the struct to a class. I just dont know how to get started and if...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.