Narue 5,707 Bad Cop Team Colleague

>Honestly speaking i don't have a clue what this means.
It means you didn't define removeFromFront for List. You declared the member function, but because it was never defined, the linker complains when it tries to find it.

Narue 5,707 Bad Cop Team Colleague

>and don't know stating i am a female can causes some misunderstanding
There's no misunderstanding at all, it just has connotations that I find insulting for women as a whole.

>fprintf(temp, "%i %*c %c %*c", ID, Name, Gender, Department);
Format modifiers for scanf and printf are not the same. The asterisk modifier for scanf means to discard the value, but for printf it means that the field width is specified by an argument. So you're trying to print ID characters from name (which is probably wrong), then one character of Gender, then all hell breaks loose because you don't have enough arguments after that.

Repeat that explanation as necessary for the number of offenses in your code.

That's the problem you know of. The problems you don't know of are many and they include:

>fflush(stdin);
This has undefined behavior.

>while(!feof(rec)){
feof is not designed to be used as a loop condition, so to avoid file reading problems you need to use ugly ad hoc workarounds.

These are only the real problems. Portability problems, error handling problems, clarity problems, etc. weren't mentioned.

Narue 5,707 Bad Cop Team Colleague

>i'VE ALREADY DONE THE PROGRAM
So you say. In my world, you prove that you've done the work. Talk is cheap.

>iF i DIDNT HAVE IT i WOULD BE POSTING IT IN 2 DAYS DUHHHH!!!!
If you didn't have it and someone did it then you would also have it in 2 days and could turn it in for your class, duhhhh. :D

>edited by alc6379
You're trying to cheat and I caught you. You've proven your guilt through the rule of "he doth protest too much", so I'm going to plonk you because you're a silly little lamer who's not worth my time. If you have a problem with that, please direct any complaints to /dev/null.

*plonk!*

Narue 5,707 Bad Cop Team Colleague

>It took me about 2 days but I got it lets see if you can do it.
>Challenge ends on October 27 the program will then be posted for you viewing
Geez, you'd think that people would be more creative than this. Do you want to know how many times I've seen this lame ploy to get other people to do your homework?

Narue 5,707 Bad Cop Team Colleague

>Well can sumbody please refer me a good UP-TO-DATE C++ book.
I already have. But if it was written after 2003 then it's probably a safe bet that it's up to date.

Narue 5,707 Bad Cop Team Colleague

>and error still occured pls help
You didn't specify what the error was.

>I am a girl doing my 1st simple program
"Oh great, is Narue going to bash the title now?" Yes. :) First, it's not informative at all. Second, it has useless information. We don't care if it's a simple program or not, nor do we care about your gender. A better title would be one that tells us what the problem is because you didn't say in the body of your post. :rolleyes:

Maybe I should make all of my re: titles "I'm a girl mocking my 93756th newbie". :mrgreen:

By the way, your code makes almost every mistake in the book. I say almost because the example is incomplete. I'm sure if it were a fully compilable example it would make every mistak in the book.

Narue 5,707 Bad Cop Team Colleague

>the Accelerated C++ is so-called a great book to learn by, well it was published in the same year as the C++ for Dummies that I have
Are you using Accelerated C++ or C++ for Dummies? If it's the former then your interpretation of the code is wrong because Accelerated C++ never uses <iostream.h>. If it's the latter, I have no comments because I haven't flipped through that book in some time and current editions may be better.

Narue 5,707 Bad Cop Team Colleague

>Does anybody know if this software is great
It works fine for my purposes.

>what are the best features of it
It works fine for my purposes. ;)

>Other recommendations are also welcome.
Borland C++ 5.5 and Dev-C++ are both free and good quality.

Narue 5,707 Bad Cop Team Colleague

>What do you mean replace the standard queue adaptor with my queue?
push and pop are equivalent to enqueue and dequeue. Any other changes to use your queue instead of the standard C++ queue are painfully obvious if you give it a shot. Play around with the code and you'll figure it out. What more did you expect me to do? I gave you the answer.

Narue 5,707 Bad Cop Team Colleague

>but its not compiling
I can't imagine why. Here's an idea, maybe it's because you can't seem to tell the difference between C++ and Java. :rolleyes:

I'd make an attempt to help you if I thought it would do any good.

Narue 5,707 Bad Cop Team Colleague

>i couldnt finish it cuz i have 2 exams cal2 and physics 2 tomo..
Tough beans. Learn to start your work sooner or prioritize the homework that's most important and accept the failing grade that you deserve for the homework you're unable to finish. Do you think that when you get out into the real world and can't finish a project you can just palm it off on someone else and they'll happily do it for you? No, you'll get fired because you weren't able to do the job you were hired for. And you'll deserve it too.

Narue 5,707 Bad Cop Team Colleague

>no, the only global variables i have are
Those are different from your first post.

>my locals:
I see an n that's declared as int.

>next = index + 1;
This line is trying to compute an offset from index and assign it to next, but next is not a pointer.

>last = tot_n - index;
Subtracting a pointer from an integer makes no sense.

>if (nums[index] > nums[next])
index is a pointer, not an integer. Array indices must be integral.

>tmp = nums[index];
This is the same problem.

>nums[index] = nums[next];
And here as well.

Narue 5,707 Bad Cop Team Colleague

n is a highly suspect name for a global variable. Did you accidentally declare a local variable n that was not an array? The global n would be hidden by the local n and you would get that error.

Narue 5,707 Bad Cop Team Colleague

>I dont think its the book source
Unfortunately, you can only accurately judge the quality of a book if you know the topic it covers intimately. If your book uses <iostream.h> then it's too old to be used as a book to jumpstart your learning.

>the book is great.
I'm getting flashbacks to when beginners were hailing the godawful books of Herbie Schildt because they were easy to understand. *shudder*

>I am trying to save up for Microsoft Visual C++ "Standard".
There are free compilers that are high quality and support the latest C++ standard. Lack of cash is no excuse, I'm afraid.

>Do you think thats a good C++ Compiler?
I use it primarily, and I haven't had any issues with it yet.

Narue 5,707 Bad Cop Team Colleague

>If you can just help me debug it
I'll help, but I'm not going to do it for you. Debugging is what the majority of programming is, so if I did it for you then you would learn nothing. As it is, you didn't specify what the error was in the first program, and I have better things to do than figure out what you think is wrong with it then tell you so that you can claim m4d debugging sk1llz. :rolleyes:

>qsort (list, 10, sizeof(int), compare); //error
You can't call a function in a class definition.

>if (bsearch(&key,list,10,sizeof(int),compare)) //error
Is the error "Unrecognized function" or something similar? Tell us what the errors are! And include <cstdlib> because that's where qsort and bsearch are declared.

Narue 5,707 Bad Cop Team Colleague

>the program is not working am unable to find whats wrong.
It could be all of the awful constructs you use... :rolleyes: I won't mention them again because I described them in detail for your other post.

>am using turbo c++
Get. A. Newer. Compiler. Turbo C++ is ancient, and not only are you missing out on all of the cool stuff that C++ has learned since that silly compiler, you also drive away potential helpers for your problems because they have to perform extensive surgery just to get your pre-standard code to even compile!

Anyway, the following is how to calculate a Fibonacci number and return true if the argument matches it, false otherwise.

#include <iostream>

using namespace std;

bool check_fib ( unsigned long int val )
{
  unsigned long int a = 0, b = 1, c;

  if ( val == 0 || val == 1 )
    return true;

  for ( int i = 2; i < 45; i++ ) {
    c = a + b;

    if ( val == c )
      return true;

    a = b;
    b = c;
  }

  return false;
}

int main()
{
  unsigned long int val;

  cout<<"Enter an integer: ";
  cin>> val;

  if ( check_fib ( val ) )
    cout<<"The number is part of the Fibonacci series"<<endl;
}

Though a much better option because the length of the Fibonacci sequence is severely limited with C++ data types is to use a table driven method:

#include <cstddef>
#include …
Narue 5,707 Bad Cop Team Colleague

>Can someone tell me what is wrong with it?
Just about everything. You're also overcomplicating things and it's pretty obvious that you aren't referring to any book on C++ or trying to compile this or you wouldn't have such dreadful syntax errors.

Use this as a template:

#include <cctype>
#include <iostream>

bool is_vowel ( int ch )
{
  ch = std::tolower ( static_cast<unsigned char> ( ch ) );
  return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
}

int main()
{
  char ch;
  int vowels ( 0 );

  std::cout<<"Enter a sentence: ";
  while ( std::cin.get ( ch ) && ch != '\n' ) {
    if ( is_vowel ( ch ) )
      ++vowels;
  }

  std::cout<<"The number of vowels was: "<< vowels <<std::endl;
}

But I should give you fair warning. If you copy parts of my code, you'll get a failing grade because it's written to make it obvious that you didn't come up with it on your own. :)

Narue 5,707 Bad Cop Team Colleague

>1. What exactly is the purpose of white spaces?
Whitespace serves two purposes. First, it separates certain tokens that cannot be immediately adjacent. For example, this is valid C++:

int i;

But this is not:

inti;

At least, it isn't valid unless you've declared a name called inti prior to that line that could be legally used in such a way. :)

The second use for whitespace is formatting. This is hard to read:

#include<iostream>
struct node{
int data;node*next;node(int init,node*link): data(init),next(link){}};
node*insert_ordered(node*list,int data)
{if(list==0){//Empty list
list=new node(data,0);}
else if(data<list->data){//Head insertion
list=new node(data,list);}
else{//Internal insertion
node *it=list;//Find the end of the list or the first larger item
while(it->next!=0&&data>it->next->data)
it=it->next;//Insert before the first larger item
it->next=new node(data,it->next);}
return list;}
int main()
{node*list=0;
for(int i=0;i<10;i++)
list=insert_ordered(list,rand()%100);
for(node*it=list;it!=NULL;it=it->next)
std::cout<<it->data<<' ';
std::cout<<std::endl;}

But this is much easier to follow:

#include <iostream>

struct node {
  int data;
  node *next;

  node ( int init, node *link )
    : data ( init ), next ( link )
  {}
};

node *insert_ordered ( node *list, int data )
{
  if ( list == 0 ) {
    // Empty list
    list = new node ( data, 0 );
  }
  else if ( data < list->data ) {
    // Head insertion
    list = new node ( data, list );
  }
  else {
    // Internal insertion
    node *it = list;

    // Find the end of the list or the first larger item
    while ( it->next != 0 && data > it->next->data )
      it = it->next;

    // …
Narue 5,707 Bad Cop Team Colleague

>thanks
What for? You didn't ask a question.

Narue 5,707 Bad Cop Team Colleague

>#include<iostream.h>
No, not C++.

>#include<iomanip.h>
Also not C++.

>#include<conio.h>
Not only is this not C++, it's also only available on a limited number of implementations.

>void main()
This never has been, and hopefully never will be, correct C++. main returns int. In fact, the old argument of being a lazy bastard ("void main means I don't have to use 'return 0;' at the end of main") doesn't apply anymore because main returns 0 implicitly. So doing things the right way actually saves you a keystroke! :)

>clrscr();
If getch is the patron saint of nonportable functions, clrscr is it's god. Not only is this functionality rarely needed in valid situations, calling it at the start of a program is almost never a valid situation.

>getch();
The patron saint of nonportable functions, but for this use you can replace it with cin.get() and have a similar effect. Sure, you require the user to hit enter instead of any key, but what do they usually hit anyway? :rolleyes:

On to the meat of the problem, unless you know of a clever way to solve the problem (I do, and I'll post it because there's no way you can turn it in as your work), you need three loops. The first loop handles the rows, the second loop is nested inside the first loop and handles leading whitespace, and the third loop comes after the second loop and prints the requisite …

Narue 5,707 Bad Cop Team Colleague

>system("pause");
>put getch();
You know what I find funny? The fact that every time this question is asked, the first two replies suggest the first two absolute worst options. :rolleyes: system is slow, nonportable, and a serious security hole and getch is the patron saint of nonportable.

>What can I do to keep the program running using Command Prompt.
The first thing you need to do is start using correct C++. iostream.h is not a C++ header, so either your compiler is frightfully old, or you aren't learning from the right source. Here is the corrected code with one solution for your command line problem:

//
// Program to convert temperature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius  * (212 - 32)/100 + 12
//
#include <iostream>

using namespace std;

int main()
{
  // enter the temperature in Celsius
  int celsius;
  cout << "Enter the temperature in Celsius: ";
  cin >> celsius;

  // calculate conversion factor for Celsius to Fahrenheit
  int factor;
  factor = 212 - 32;

  // use conversion factor to convert Celsius into Fahrenheit values
  int fahrenheit;
  fahrenheit = factor * celsius/100 + 32;

  // output the results
  cout << "Fahrenheit value is: " << fahrenheit << endl;

  // remove extraneous characters from the input stream
  char ch;
  while ( cin.get ( ch ) && ch != '\n' )
    ;

  // pause until the user hits Enter
  cout << "Press Enter to continue...";
  cin.get();
}

Other (cooler) …

Narue 5,707 Bad Cop Team Colleague

You don't have to break everything up into functions at this point, just solve the different parts of the problem separately. Write a program to take the proper user input, write a program to make change, write a program to eat money randomly. Then, you know how to do each of the parts and can put them all together into one program. You can probably even transplant code from your other programs into the big program. Breaking up a problem into several solvable problems doesn't require modularization like you seem to think.

Narue 5,707 Bad Cop Team Colleague

>really didnt found it on net
BS. Just about every google hit on the first page of a search for "infix prefix postfix conversion" looks promising. Either you didn't search as hard as you're suggesting, or you were too lazy to try searching and thought we would fall for a lie.

Narue 5,707 Bad Cop Team Colleague

>_MY_HEADER_FILE_
This invades the implementation's name space. Names with a leading underscore have a tendency to be reserved by the language definition for an implementation's use.

Narue 5,707 Bad Cop Team Colleague

>help with getting soda machine program running

bool fix ( const soda_machine& machine)
{
  kick ( machine );
  slap ( machine );
  shake ( machine );
  curse_at ( machine );

  return machine->is_working;
}

...

if ( !machine.is_working && !fix ( machine ) )
  call_repairman ( machine.serial_number );

But seriously, if you divide your program into easy chunks, you won't encounter problems like this. :) I believe that your problem is trying to bite off more than you can chew, then choking on it.

Narue 5,707 Bad Cop Team Colleague

Header files are just textual replacement. When you say

#include "Person.h"

That line is replaced with the contents of Person.h. In other words, everywhere you include Person.h, you get this:

#include <string>

class Person
{
public:
  Person(char * name = 0,int age = 0);
  Person(Person const & p);
  Person& operator=(Person const & rhs);
  virtual ~Person();
  void Display() const;

private:
  char* name_ ;
  int age_;
};

So let's do a little test:

class A {
};

class A {
};

Compile this and see which error you get. Mine is a redefinition error for class A. This is exactly what is happening in your program, and the easiest way to fix it is to wrap the header file in a conditional compilation statement:

#ifndef PERSON_H
#define PERSON_H

class Person
{
public:
  Person(char * name = 0,int age = 0);
  Person(Person const & p);
  Person& operator=(Person const & rhs);
  virtual ~Person();
  void Display() const;

private:
  char* name_ ;
  int age_;
};

#endif

You'll also notice that I removed the include of <string> because it's not needed. You don't declare anything that requires a name from that header, so don't clutter up your code by including it.

Narue 5,707 Bad Cop Team Colleague

>Can anyone out there help me write the "Main" part.

#include <iostream>
#include <queue>

using namespace std;

int main()
{
  queue<char> q;
  char ch;
  bool match = true;

  cout<<"Enter a message: ";
  while ( cin.get ( ch ) && ch != '\n' )
    q.push ( ch );

  cout<<"Enter another message: ";
  while ( cin.get ( ch ) && ch != '\n' ) {
    if ( q.empty() || q.front() != ch )
      match = false;

    q.pop();
  }

  if ( match )
    cout<<"The two messages match"<<endl;
  else
    cout<<"The two messages do not match"<<endl;
}

Replace the standard queue adaptor with your queue and that's it!

Narue 5,707 Bad Cop Team Colleague

What did you try and where did you search? I get plenty of hits on google for this sort of thing, and several books go over it during their explanation of stacks.

Narue 5,707 Bad Cop Team Colleague

Nobody is going to download 5 files just to help you. My suggestion is that you remove everything you can without removing the error itself (but if you do, note what you took out). Then you'll be in a better position to debug. Who knows? The code may be short enough to post here at that point.

Narue 5,707 Bad Cop Team Colleague

You don't declare types in a function call:

addFraction (numerator1, denominator1, numerator2, denominator2, numeratoranswer, denominatoranswer);

And check your spelling, particularly for numeratoranswer.

Narue 5,707 Bad Cop Team Colleague

>int *a = malloc(10 * sizeof *a);

Most compilers will complain because malloc() returns void* and, in C++, you need to cast void* to the type you are mallocing.

Generally, you should use 'new' and 'delete' rather than malloc, for at least these three good reasons:
1) You don't need to cast
2) As Dave pointed out, malloc(10) allocates 10 BYTES, not 10 ints
3) Constructors are not called. Not a big deal with ints, but a huge deal with objects.

In this case,

int* a = new int[10];
delete [] a;

note the need for [] in the delete; if you used [] in new, use them in delete.

>Using C memory allocation routines in C++ programs is BAD FORM.
I see nothing in the original post that suggests either C++ or C. As the answer is directly related to the language, don't you three think it makes sense to ask before going off on your favorite tangent?

>what happened if we do't typecast return value of malloc
In C, nothing because pointers are implicitly converted to and from void without the need for a cast. In fact, it is best to avoid the cast in C because it hides errors.

In C++, you would get a compile-time error because C++ does not bless implicit pointer conversions to and from void. A cast is required, but it's better to use new in C++ for several reasons that I won't mention because …

Narue 5,707 Bad Cop Team Colleague

>I"ve done all the changes
Prove it.

>but still it wont run
What's it saying?

>please help
You're not helping us to help you, so you won't get much help.

Narue 5,707 Bad Cop Team Colleague

>so it's not quite so easy
Sure it is. The way cin's >> operator handles whitespace makes it easy:

#include <iostream>

using namespace std;

int main()
{
  int num, den;

  cout<<"Enter a fraction: ";
  cin>> num >> den;

  cout<< num <<'/'<< den <<endl;
}

The really nifty part is that you can break up that call into two calls and it works the same way:

#include <iostream>

using namespace std;

int main()
{
  int num, den;

  cout<<"Enter a fraction: ";
  cin>> num;
  cin>> den;

  cout<< num <<'/'<< den <<endl;
}

Wrapping everything in a function is trivial as well:

#include <iostream>

using namespace std;

bool get_fraction ( int& num, int& den )
{
  return cin>> num >> den;
}

int main()
{
  int num, den;

  cout<<"Enter a fraction: ";
  if ( !get_fraction ( num, den ) )
    cerr<<"Invalid input"<<endl;
  else
    cout<< num <<'/'<< den <<endl;
}
Narue 5,707 Bad Cop Team Colleague

>I'm really drawing a blank as far as how to setup the function that reads the fractions inputed by the user.
It's as simple as reading two integers and saving them in numerator and denominator variables.

Narue 5,707 Bad Cop Team Colleague

do..while loops end with a semicolon:

} while(!infile.eof());

But, tell me what happens when the input file is empty? Your do..while loop will still process a character, but it will be uninitialized and the result is undefined behavior. A while loop is better, but don't use stream.eof() as the loop condition, bad things can happen. Try this instead:

while ( infile.get ( in ) )
  cout<< in;

Also, the way you use the file streams is awkward. You can open the file through the constructor (and ignore the ios::in and ios::out parts because you use ifstream and ofstream, respectively. They're only needed for fstream objects) and the destructor closes the files automagically:

#include <iostream>
#include <fstream>

using namespace std;

int main ()
{
  char in;
  ifstream infile ( "in.dat" );
  ofstream outfile ( "out.dat" );

  if ((!infile) || (!outfile))
  {
    cout << "error opening file\n";
    return 0;
  }

  while ( infile.get ( in ) )
    cout<< in;

  return 0;
}
Narue 5,707 Bad Cop Team Colleague

The function works properly when I test it. What is it doing that it shouldn't?

Narue 5,707 Bad Cop Team Colleague

>Is there an easy fix?
Yes, make all of those variables double. If you declare them as integers then it would be a bad idea to pretend they are floating-point with an input function that takes you very literally. Since the decimal point is not a valid integer, cin is choking on it.

Narue 5,707 Bad Cop Team Colleague

>Is it possible to do it this way?
No, what I showed you was an initializer list for the class constructor. This list has special properties that allow you to actually initialize variables rather than just assign to them as you would have to in the constructor body. If you do not use the initializer list then the vector will be default constructed and you need to use resize:

template <class el>
class pQ
{
public:
  pQ();

private:
  vector<el> a;

};

template <class el>
pQ<el>:: pQ()
{
  a.resize ( 1 );
}
Narue 5,707 Bad Cop Team Colleague

>you're saying it's best to write a function for every operation that is
>needed and not to combine several operations in one function?
Yes, provided you do it intelligently. There's a fine line between a well modularized program and an overcomplicated mess. :)

Narue 5,707 Bad Cop Team Colleague

>I know one could increase the size of the array, but that's not challenging
Not challenging, but certainly informative when comparing methods. Because quicksort's speed isn't noticeable until the array gets very large, you won't see much difference between sorting methods no matter what kind resolution your timer is. It's best to use an array size that would be realistic for your application and span the timing across multiple calls so that you can get an average time distribution for the algorithm.

And if you're using my quicksort for 1000 items or less, that's what we in the field call "overkill". Try shellsort instead. :D

Narue 5,707 Bad Cop Team Colleague

>I believe I can do this in one function, right
Sure, though it's best to restrict functions to performing one operation. For example, a function to get a number from the user that treats 0 as a terminating condition can be reused in a great many programs. If the function also checks array boundaries, it isn't as flexible and you won't find yourself reusing code that you've already written and debugged.

Narue 5,707 Bad Cop Team Colleague

Narue,
I can pass by address, not by reference. I appreciate any help you can give. Thank you for responding. Paul

Just to clarify, passing by value is this:

void f ( int param );

Passing by address is this:

void f ( int *param );

And passing by reference is this:

void f ( int& param );

The problem with your code is that you declare functions to pass by value, but you then seem to expect the same effect as if you passed by reference or address. The most notable statement that you made, and the one that confuses me the most is this one:

and all functiontions must keep the header type below.

I read this as meaning that the function return type and parameter lists could not be changed. Is that true or not? Because this is wrong (any anything similar):

int ID, <snip>; // ID is uninitialized

...

// ID is still uninitialized, you seem to expect to pass it by reference here
result = getEmployeeData (ID, pyrllSt, quit, Salary, hourwrk, sales, grossPay);

...

// ID is still uninitialized. At this point you will invoke undefined behavior
displayEmployeeInfo (ID, pyrllSt, grossPay);

...

// Once again, undefined behavior.
calculateGrossPay(ID, pyrllSt, Salary, hourwrk, sales, grossPay);

The problem could easily be fixed if you change getEmployeeData to take references for any variables that it gives values to and the code expects to be initialized when the function returns:

bool getEmployeeData (int&, char&, …
Narue 5,707 Bad Cop Team Colleague

>for int (int i=0; i<MAX; i++)tabel=i+1;

for (int i=0; i<MAX; i++)cin>> tabel[i];

>void main (void)
In C++ this must be:

int main()

You can keep the void argument, but it's really not necessary for symmetry like it is in C. But the important part is that main must return an int, it's non-negotiable.

You have several other errors, but I'll assume that's because you typed the code in manually and didn't check yourself.

Narue 5,707 Bad Cop Team Colleague

The harsh reality is that you'll learn more on your own or on the job than you will from college. Since that's the case, pick the school that will look best on a resume and do all of the following in your spare time:

1) Read, read, read.
2) Practice programming by tinkering with toy projects. This gives you an in depth understanding of how things work.
3) Work on an open source project. This gives you real development experience and also puts your name in the pool for fishing employers.

Narue 5,707 Bad Cop Team Colleague

It looks like a faulty installation. Remove Visual Studio and try again, this time watching for any errors that crop up during installation.

Narue 5,707 Bad Cop Team Colleague

Your problems all stem from this line:

vector<el> a(1);

First and foremost you need to remember that any standard names are in the std namespace. If you don't have a using declaration (using std::vector;) or a using directive (using namespace std;) then you need to qualify the declaration explicitly:

std::vector<el> a(1);

The second problem is that you're trying to call a constructor in a class declaration. Because this isn't executable code, you want to remove the argument list:

std::vector<el> a;

Then you can call the constructor of a in the constructor of pQ:

template <class el>
class pQ
{
public:
  pQ()
    : a ( 1 )
  {}
public:
  std::vector<el> a;
};

Though because vectors grow dynamically, you typically don't need to worry about this and can just rely on push_back working it's magic. Only in extreme cases of performance or if the vector is not likely to change its size do you want to set a base size or preallocate a certain amount of memory.

Narue 5,707 Bad Cop Team Colleague

Reducing a fraction is pretty easy with the GCD:

#include <iostream>

using namespace std;

int gcd ( int m, int n )
{
  return n ? gcd ( n, m % n ) : m;
}

int main()
{
  int num, den;

  cout<<"Enter a fraction: ";
  cin>> num;
  cin.get();
  cin>> den;

  int div = gcd ( num, den );
  cout<<"The reduced fraction is "<< num / div <<'/'<< den / div <<endl;
}

Though you should take that GCD function with a grain of salt. It's quick and dirty. ;)

Narue 5,707 Bad Cop Team Colleague

Welcome aboard! I hope your experience is a good one. :)

Narue 5,707 Bad Cop Team Colleague

>i would appreciate if you could do it for me!!
Sorry, but I refuse. My reasons are as follows:

1) This is your program, not mine. I don't care about it at all.
2) Writing a shell is an amazing learning experience. If I did this for you then you would miss out on a lot of useful knowledge.
3) I've already written a shell that was much more fully featured than this one. I've solved the problems that arise and gained valuable experience in the process. There's no need for me to do it again, but it would be beneficial for you to do it.

If you need help with any part of it, I'll be glad to offer advice. But I'm not going to do it for you, and nor will anyone else you ask.

Narue 5,707 Bad Cop Team Colleague

>Help is greatly appreciated.
Which parts are you having problems with? In the code you posted, tryAgain is missing a closing brace for the function body, so it doesn't compile. After that it does, but there are quite a few warnings ranging from type mismatches to unused parameters to uninitialized variables to execution paths that don't return a value.

I would rewrite your code to correct these things and explain why I did what I did, but it still would not work correctly with your restriction that the function return values and parameter lists cannot change. The biggest problem is in passing variables by value, but using them as if they were passed by reference. So my second question is why can't you change the function declarations when they seem to be wrong?