C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

simple c++ question for array

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Jun 06, 2006 6:44 pm    Post subject: simple c++ question for array Reply with quote



Hi,
I just started c++ programming. Could you please give some tips for how
to define this simple problem.

Say, I have 30 carriers from carrier number 35 to 65. Now these
carriers may be 1 bit,2 bit or 4 bits.
I can define this

b[]={1,2,4}; // b(bit loading information) is an int which can be 1,2
or 4 bits.

if c is the carrier then how do I relate this c to b. For example
carrier number 36 can be 1/2 or 4 bits.

Please help me. It might be a stupid question for you guys but beginner
like me want to learn the basics.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Victor Bazarov
Guest





PostPosted: Wed Jun 07, 2006 3:02 am    Post subject: Re: simple c++ question for array Reply with quote



hussain.rezwan (AT) gmail (DOT) com wrote:
Quote:
[...]

Say, I have 30 carriers from carrier number 35 to 65.

Unless you exclude one of the ends, it's 31 carriers. But it really
has no bearing on the problem, methinks.

Quote:
Now these
carriers may be 1 bit,2 bit or 4 bits.
I can define this

b[]={1,2,4}; // b(bit loading information) is an int which can be 1,2
or 4 bits.

I am not sure I understand the problem. Why not give each carrier
a data member that would define how many bits it carries?

Do you expect 'b' to be defined outside of the 'carrier' and possibly
change at run-time to something like {3,5,7} ? What's the relationship
between a carrier and 'b' in your model?

Quote:
if c is the carrier then how do I relate this c to b. For example
carrier number 36 can be 1/2 or 4 bits.

Why do you think you need to "relate" anything to anything? What is
it you're trying to model here?

Quote:
Please help me. It might be a stupid question for you guys but
beginner like me want to learn the basics.

You're starting from a wrong end. First design the interface of your
carrier, then define its implementation. What's the interface? How
is it going to be used? Apparently not enough information provided.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.