Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,070 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,609 people online right now. Registration is fast and FREE... Join Now!




declare function

 
Reply to this topicStart new topic

declare function, seat assignment

KMH
11 Apr, 2008 - 07:15 PM
Post #1

D.I.C Head
**

Joined: 23 Mar, 2008
Posts: 80

hello,

If I want to declare the function for passengers seat assignmnet like below what can I use as a function?? part int and part string or is there a better way to do this?? Can anyone give example please.

CODE


   xxxx= "1A","2A","3A","4A","5A","6A"; this Aile seat
   xxxx= "1B","2B","3B","4B","5B","6B"; this window seat
row_num = 6;

if(seatchioce = w)
            {
             cout << "These are option for Window seats availale: " << num2 << endl;
          }
          /*else if(seatchioce = a)
             cout << "These are option for Aile seats available: " << num1 << endl;
          else
             cout << "and these are row option available: " << row_num <<


This post has been edited by KMH: 11 Apr, 2008 - 07:33 PM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Declare Function
11 Apr, 2008 - 08:42 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well if you think about it, these seats are going to map to a mutli-dimensional array so why not pass in a row number and a seat letter. That way you can just translate which letter is which number for your array.

For instance, you would call your function like assignSeat(1,'B') which would then translate 'B' into array subscript 1 (because your arrays start at 0). So this would assign the seat with subscript [0][1] in your array.

Might be one implementation you can go with. smile.gif


User is offlineProfile CardPM
+Quote Post

KMH
RE: Declare Function
12 Apr, 2008 - 08:30 PM
Post #3

D.I.C Head
**

Joined: 23 Mar, 2008
Posts: 80

Hi Martyr2,

Thanks for your rplied, I see what you mean, yes that way I don't have to declare row and seat number seperately. Can I declare the function like this: int assignSeat(int seat_num, int row_num, int pass_num);??? Will (1,'A', 1,'B' ....etc) print 1A, 1B ....?? Do I need to worry about array element 0??? Sorry for asking dum question.

Best Regards,

Sopear


QUOTE(Martyr2 @ 11 Apr, 2008 - 09:42 PM) *

Well if you think about it, these seats are going to map to a mutli-dimensional array so why not pass in a row number and a seat letter. That way you can just translate which letter is which number for your array.

For instance, you would call your function like assignSeat(1,'B') which would then translate 'B' into array subscript 1 (because your arrays start at 0). So this would assign the seat with subscript [0][1] in your array.

Might be one implementation you can go with. smile.gif


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 07:07PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month