freemind 0 Junior Poster in Training

Lesson learned but unfortunately the fact persists for our very case. Since I have the 2 options now - either to rewrite everything or to try to correct it as it is I'm a bit more for the second option. Notice taken, though.

freemind 0 Junior Poster in Training

freemind: You know that you're not supposed to put function bodies or variable definitions in a header, right? (Well, now you do.)

I will read on this topic, thanks.

I may actually help more later on, but there are many things that make this code difficult to look at and understand. So I'm taking my time.

If you are so kind to share these things with me I could use the time to correct the outlook of the program.

freemind 0 Junior Poster in Training

Generally you're right about the testing. I can't think of a way, though, to check every function, especially when one function often uses the other from the same class and executable code is produced only when all the used functions are written down. Once the whole picture is clear I can start tracking down the problems.

As for delete[] - this belongs to the last actions I have to do. My primary concern at the moment is that the code starts running as it is supposed to do :-) Optimization belongs to the last stage before giving up the ready code and will be done, I can assure you.

freemind 0 Junior Poster in Training

liblifts.h is the dirty worker in this case so this is the place. I presume that the Elevator class is the primary and probably almost only source of errors. The open_doors() function and the move() function are probably most critical. If I must be sincere - I don't have an exact idea what's wrong .. if I did have one I would try to correct the code myself.

freemind 0 Junior Poster in Training

I found a plase to paste it: http://rafb.net/paste/results/Jqrme337.html

freemind 0 Junior Poster in Training

They will make no sense without the other code. Besides the program is divided into files, besides the function and namespace division..

freemind 0 Junior Poster in Training

Hi everybody! I recently wrote a little simulation program, that simulates a real-time elevator system with 3 elevators. Since the code is around 530 lines I presume it is not a good idea to paste it here. There is some number of minor flaws of logical type and I would be very thankful on any ideas or corrections.

Since I don't posses any web space and I believe that corrections will be (probably) move obvious on a personal machine I can send the code to the email of anybody who's interested. I guarantee that no harmful programs will come with the email, in case somebody may think so.

If somebody is interested please answer to this post or send me a personal message with your email. If you have a better proposition than the email option that I can think of at the moment - please, of course, share it with me :)

Thanks to all in advance!

freemind 0 Junior Poster in Training

Perhaps the second :-) Thanks!

freemind 0 Junior Poster in Training

Default constructor i don't need in this case, because i need to set up some predifined values for buttons and states. I'm still a bit confused how to edit my code so it's working, though. As for the

stats = Status(1);

maybe it's an error but i haven't done any C++ programming in quite a while and also the compiler doesn't recognize it as an error. Until the testing comes a lot of code is to be written but the pebble in the shue is still there..

freemind 0 Junior Poster in Training

Hi to all! I'm writing a simple simulation program for elevators but i get a problem, namely:

elevator.cpp: In constructor `Elevator::Elevator(int)':
elevator.cpp:41: error: no matching function for call to `Button::Button()'
elevator.cpp:10: note: candidates are: Button::Button(const Button&)
elevator.cpp:16: note:                 Button::Button(int, bool)
elevator.cpp:41: error: no matching function for call to `Button::Button()'
elevator.cpp:10: note: candidates are: Button::Button(const Button&)
elevator.cpp:16: note:                 Button::Button(int, bool)
elevator.cpp:44: error: `Buttonset' undeclared (first use this function)
elevator.cpp:44: error: (Each undeclared identifier is reported only once for each function it appears in.)
elevator.cpp:45: error: no match for 'operator=' in '((Elevator*)this)->Elevator::Alert = (((Button*)operator new(8u)), (<anonymous>->Button::Button(3, 0), <anonymous>))'
elevator.cpp:10: note: candidates are: Button& Button::operator=(const Button&)

The code that produces this minor irritation is the constructor of the 2nd class:

class Button {
      private: 
               enum Types {inside, outside, alarm};
               Types type;
               bool active;
      public:
               Button(int typ, bool state) {
                      if (typ!=1 && typ!=2 && typ!=3)
                                 throw ("Crappy button type in initialisation...Terminating.");
                      if(state!=0 && state!=1)
                                  throw("Boolean expected in button class initialisation... Terminating.");
                      type = Types(typ-1);
                      active = state;
               }
                      
               inline bool is_active(void) { return active; };
               inline int  who(void) { return type; };
               inline void flashb(void) { active=!active; };
               inline void press(void) { active = 1; };
};
class Elevator {
      private:
              int number;
              Button ButtonSet[10];
              Button Alert;
              queue<int> queue;
              int last_stop;
              enum Status { moving, idle, alert };
              Status stats;
      public:
             Elevator(int num) {
                          number = num;
                          for(int i=0; i<10; i++)
                                  Buttonset[i] = new Button(1, 0);
                          Alert = new Button(3, 0);
                          stats = Status(1);
             };
             void pressb (int num);
             void emergency(void); …
freemind 0 Junior Poster in Training

Don't forget that C++ gives you the opportunity to use string instead of char[]. Combining this with the usage of find() and substr() can solve your problems.

freemind 0 Junior Poster in Training

The documentation of your compiler keeps the answers to many "secrets". Besides ALPHA and BETA releases of programs carry these names for the sole reason to say that they are still unfinished.

freemind 0 Junior Poster in Training

tank you guys!
temp *= num--;

temp *= num--; is equivallent to: temp = temp*(num-1);
temp += 5; is equivallent to: temp = temp + 5;

The shorthand operators are basic and useful, due to their simplicity and length.

freemind 0 Junior Poster in Training

The simplest way is to use a loop. A for(unsigned long i=user_input; i > 1; i--); could be one solution.

freemind 0 Junior Poster in Training

Then consider using another compiler.;) If you want to start over when something in the user's choice goes wrong you can either provide an ethernal loop around the code that should be performed over and over again until the user gives a correct input or use labels. I recommend you the first option. If you choose the second one you would probably want to know something about "goto"...

freemind 0 Junior Poster in Training
[left]#include<iostream>
#include<string>
using namespace std;

class employee
{
string first;
string last;
int salary;

public:
void getdata(void);
void setdata(void);

employee()
{
salary = 0;
last="";
first="";
}
};
 
void employee::getdata(void)
{
cout<<"\na first name: " << first;
cout<<"\na last name: " << last;
cout<<"\nmonthly salary: " << salary;
}
void employee::setdata(void)
{
cout<<"first name?: ";
cin >> first;
cout<<"last name?: ";
cin >> last;
cout<<"monthly salary?: ";
cin >> salary;
}

int main()
{
	employee E;
	E.setdata();
	cout << "\n Stuff just entered: \n";
	E.getdata();
return 0;
}[/left]

There you go.

freemind 0 Junior Poster in Training

Maybe something like: extern char mir[200]; in test.h can solve your problem ?

freemind 0 Junior Poster in Training

Since strings in C are arrays of characters and an array is something quite trivial to programming languages, you don't need to import libraries to get strings to work. You can make your life easier, though, by using headers, that include various functions for string manipulation (string.h for example.) The double quotes show that you are about to use a string, instead of a single char(refferred to with a single quote 'a','b'.. and so on). This could be looked at also from the point of view - making it possible to live and program without committing a suicide when you try to use a string. Imagine instead of writing char bla[] = "I love icecream\0"; to had to write char bla[16]; bla[0] = 'I'; bla[1] = ' '; bla[2] = 'l', etc. or char a[] = {'a','b','c','\0'};. To complete the definition of a string in C you have to remember that every char array(string) has '\0' as a last member, i.e. strings in C are zero-terminated.

Direct string support and respectively a string class is supported in C++.

freemind 0 Junior Poster in Training

Nice. :-)

freemind 0 Junior Poster in Training

I'm reading your post and I can't really get what the problem is, especially with the decimal.. The reminder you can find using the % operator. More information and details you can find here: http://www.intap.net/~drw/cpp/cpp03_04.htm

freemind 0 Junior Poster in Training

Although it's not for VC++ you can look through the code of cyber_azis and find some answers. There is a Borland library adapted for Dev-Cpp (another C++ compiler) that gives you the opportunity to create console graphics. There is a topic on this and more detailed explonation in the code snippets section of this site. Good luck.

freemind 0 Junior Poster in Training

Simple. Always get stuff from the user as a string. Then check it and get from it what you need. If you don't find it - shoot an error and let a new input be given. There are some lines of code that you pasted there.. it's quite long for somebody to look through it and simplify it. After some time, when you become a better programmer go through the program yourself and make it better!

freemind 0 Junior Poster in Training

more quesion , namespace is only related to header file?

No. std is to iostream.h (cstdio.h respectively) but namespaces are just logical units holding whatever belongs in a logical way together.

Ex.:

namespace simple_operations { 
		   double sum(double a, double b) { return a+b; };
		   double mul(double a, double b) { return a*b; };
		   // ....
}
freemind 0 Junior Poster in Training

ups.. :rolleyes:

freemind 0 Junior Poster in Training

include conio.h and use getch();

freemind 0 Junior Poster in Training

If you're so kind to post some errors that you get, as well as a brief information about the platform that you're trying to install/use it on, maybe someone can answer you..;)

freemind 0 Junior Poster in Training

Since everybody is against the idea I'll play for it. Yes, that is Dave! (I'm searching for supporters!:cheesy: )

freemind 0 Junior Poster in Training
freemind 0 Junior Poster in Training

You can write a program to create all these things. Just a random generator for the quantities. The names you can find in adventure books for children, comics, old movies/games or.. in your imagination ;)

freemind 0 Junior Poster in Training

What you're writing looks a bit more like pure C then C++. You're obviously using headers imported from Pascal to C and C++ respectively (the names of the functions you're using are calling some memories :-) ). Anyway since you're using a low-level language for something, that it's not meant to be an important aspect of it, namely graphics, you have some options left like:

1. Open your header file and look through the functions you got there. You don't need to understand them, the names will be in the most cases enough as a tip. You can google everything that looks fitting to your case.
2. You have also the option to redraw the screen. Make a function that draws exactly the same window over the already drawn one and make the screen update through it, i.e. add the new stuff after the user has selected an option(for example). This is more or less quite a hard way to get what you want, but it's still an option ..
3. Get into C++ and use the huge range of graphics related libraries. This will be quite time consuming, especially if you're new to this. In the end your program will look exactly as you want it to look, though.. ;)

// ...
do
{
ch = getch (); // gets input from user and
temp=choice; // and acts on it using ascii values
ch=getch();
// ...

You call getch() 2 times, maybe this could be …

freemind 0 Junior Poster in Training

The sorting you can do in many ways. One way could be putting all the data in let's say a class and then sort the vector of objects with ssort(), qsort() or whatever function you want. Other way could be putting the unsorted lines in a temp file, taking the first letter of every line and comparing the first letter from the next line with it (Tip: after the first letter, which is at position 0 in the file every next letter will be after a '\n'). If the corresponding condition is true you can swap the lines and go on. There are other ways probably better ones, this is what comes to me now.

The formatting you can do by creating an imaginary "name field" for the names. When you get them from the file and create the fullname you can check it's length and save it as a temporary. Consequtive checks can give you the size of the longest name. When writing the temp output file you can check the name of the student before streaming it to the file and add to it (if necessary) the number of white spaces it needs to reach the name with the max size, i.e. int bla = longest_name - fullname.size(); and add 'bla' blanks to fullname. Then you can continue with copying the scores. Since I don't know the inbuilt C++ libraries too good I can't offer you a more subtle way to do the formatting, but this should …

freemind 0 Junior Poster in Training

The last time when I used Pascal was ages ago, but I do remember a function delay(), i.e. delay(6); gives u a delay from 6 seconds. Maybe you need to use Crt (or if there is a new name for it) to get it - this you have to check.

freemind 0 Junior Poster in Training

The Art of Assembly is a book that I find quite nice, understandable and deep enough.

freemind 0 Junior Poster in Training

Gillzor, the problems with the games are in general 2 - insufficient hardware recources (you're on the limit, but I don't think this is your problem) and outdated drivers for video/monitor/directx and so on. Also the case of overcrowded windows (and registers) should be considered. Maybe you should consider a fresh install.. for windows this has helped not once and twice, specially in previous distributions.

In both cases, though, your problem is out of the scope of this forum - it has nothing to do with C/C++. Try to update your drivers, to minimize the number of running processes when starting the game (ctrl+alt+del and kill almost everything that is started by your user). If this doesn't help - reinstall windows and complete the driver and process steps again. If the problem persists - contact the creators of the games and ask them. Meanwhile you can search for patches on the net and the official sites.
Good luck.

freemind 0 Junior Poster in Training
#include <iostream>
#include <string> 
 
using namespace std;
 
class Account {
	 public:
			 Account(): balance(0.0) {};
			 inline bool checkpass(string number, string password) {
					// some way to check number and pass
					return 1;
			 }
			 inline float GetBalance() { return balance; };
			 // and so on ...
	 private:
			 float balance;
};
 
int main(void) {
	Account Account1;
	string num, pass;
 
	cout << "\n Input account number: ";
	cin >> num;
	cout << "\n Input password: ";
	cin >> pass;
 
	if(Account1.checkpass(num, pass))
			  cout << "\n Login successful!\n";
	else
			  cout << "\n Error, try again!\n"; // you'll never see this :-)
 
	return 0;
}

This is some equivalent to your code. The division in files I leave to you. ;) Be careful how you initialize an object of the class and how you call a member function through it. This is where your error comes from.

freemind 0 Junior Poster in Training

Since both programs require relatively low knowledge over the language you can try to find a few tutorials and go over them. This doesn't require too much time and it'll get you over the basics. I don't think somebody will write the code for you, but I'm sure somebody will help you with finding, understanding and correcting the mistakes you make. Give it a shot, in the end it only matters what you know. :-)

freemind 0 Junior Poster in Training

double in C++ has a 64-bit precision. long double has the same I think, which leaves you with the opportunity to use either double, or if it's not good enough for you, you can use something like this: http://members.lycos.co.uk/keithmbriggs/doubledouble.html

freemind 0 Junior Poster in Training

Rashakil Fol, you know what I mean.

freemind 0 Junior Poster in Training

I'm giving you the "I wash my hands" type of answer, namely a link to a tutorial but I hope it would prove to be useful, since it looks like covering all the important stuff. http://www.cpp-home.com/tutorial.php?26_1 is your link. On the other hand - why are you trying to send assembly code to a remote machine? I should either go to bed or it smells a bit like something else.. ;)

freemind 0 Junior Poster in Training

I wish I knew what the connection was so I could fix it and play my games :sad:

It is quite obvious what you wish. Maybe if you try to answer some of the questions you were asked somebody will be able to help you.

freemind 0 Junior Poster in Training

What is the connection between running a game and Visual C++ ? It's a bit late here but I can't find an obvious link between the two. The error that you get usualy appears when you cause an undefined (from language point of view) situation in a program. There are many examples for such stuff(using uninitialized variables is one simple case) but the consiquence is always a disaster ;) What are you actually doing ?

Don't forget that every responsible code (programs) is comming with more or less documentation with it. In such is a troubleshooting section not uncommon, maybe you'll find an answer there .. ?

freemind 0 Junior Poster in Training

Zeek, in the real world people don't use such numbers. For convenience in different sciences units are defined to mean something when the basic unit is on power (-3), (-6), (-9) and so on (as well as their positive corresponding values). Since you have put time and effort in this code it will probably be hard to leave it unfinished or if you don't want to - code it, but the problem remains - such thing is unnecessary. My advice is to redirect your efforts in C to something else. C is a very powerful and flexible low-level language and I'm sure you'll find something that suits you. I hope my advice is not discouraging!

freemind 0 Junior Poster in Training

Here I paste the edited and fully working code in case somebody is interested in it.

#include <iostream>
#include <string>
#include <list>

using namespace std; 

static const char* lala[] = {"Mobile", "Static"};

class TelB;
class AB {									  // Address Book
	  protected:
				string name;
				string address;
				string land;
	  public:
				virtual void add(list<TelB>&) = 0;
				virtual void del(list<TelB>&) = 0;
				virtual void show() const {
						cout << "\n Name: " << name << "\n Address: " << address;
						cout << "\n Land: " << land;
				};
				AB(string n, string a, string l){
							 name = (string) n;
							 address = (string) a;
							 land = (string) l;
				}
				virtual ~AB(){};
};

class TelB : public AB {					   // Telephone Book
	  private:
			  string number;
			  enum Type { Mobile = 1, Static = 2 };
			  Type Tel_type;
	  public:
			 virtual void add(list<TelB>&);
			 virtual void del(list<TelB>&);
			 virtual void show() const;
			 TelB(string n, string a, string l, string num, int type)
						 :AB(n, a, l) {
						 
						 string tmp;
						 string MobileBG = "888", MobileDE = "177";
						 string StaticBG = "00359", StaticDE = "0049";
						 
						 // Adding pre-dial stuff for the numbers(for convenience)
						 if(l == "Bulgaria")
								 if(type == 1)
											   tmp = StaticBG + MobileBG;
								 else
											   tmp = StaticBG;
						 if(l == "Germany")
								 if(type == 1)
											   tmp = StaticDE + MobileDE;
								 else
											   tmp = StaticDE;
						 
						 number = tmp + " / " + num;
						 Tel_type = (Type) type;
			 }
			 virtual ~TelB(){};
};

void TelB::add(list<TelB>& PB) {
	 string n, a, l, num;
	 short t;
	 
	 cout << "\n Please input name: "; cin >> n;
	 cout << …
freemind 0 Junior Poster in Training

I withdraw the last question. Sorry for the delay. Just changed list<TelB*> to list<TelB> and added some changes on 1-2 places. Now it works correctly. Sorry if I have taken from somebody's time!

freemind 0 Junior Poster in Training

Thanks.
Get's the job done but crashes when the list has to be shown. Since there is nothing specific about showing it I consider a possible error when adding an entry. This is only an asumption, though, but I am not quite sure if this

TelB* new_entry = new TelB(n, a, l, num, t);
	 PB.push_front(new_entry);
	 delete new_entry;

is correct. Isn't it pushing_front a wrong thing ? Since devcpp for unknown reason does't want to add debugging information to the project I can't try to debug it. So.. I ask ;)

freemind 0 Junior Poster in Training

Here I paste a simple address book/telephone book. The linker spits the following error:
g++.exe derived2.o -o "Derived2.exe" -L"C:/Dev-Cpp/lib"
derived2.o(.text$_ZN2ABD2Ev[AB::~AB()]+0x3a):derived2.cpp: undefined reference to `vtable for AB'
derived2.o(.text$_ZN2ABC2ESsSsSs[AB::AB(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x3d):derived2.cpp: undefined reference to `vtable for AB'
collect2: ld returned 1 exit status
make.exe: *** [Derived2.exe] Error 1
Execution terminated

I would be thankful for ideas on what is wrong..

#include <iostream>
#include <string>
#include <map>
#include <list>
using namespace std; 
class TelB;
class AB {									  // Address Book
	  protected:
				string name;
				string address;
				string land;
	  public:
				virtual void add(list<TelB*>&);
				virtual void del(list<TelB*>&);
				virtual void show() const {
						cout << "\n Name: " << name << "\n Address: " << address;
						cout << "\n Land: " << land;
				};
				AB(string n, string a, string l){
							 name = (string) n;
							 address = (string) a;
							 land = (string) l;
				}
				virtual ~AB(){};
};
class TelB : public AB {					   // Telephone Book
	  private:
			  string number;
			  enum Type { Mobile = 1, Static = 2 };
			  Type Tel_type;
	  public:
			 virtual void add(list<TelB*>&);
			 virtual void del(list<TelB*>&);
			 virtual void show() const;
			 TelB(string n, string a, string l, string num, int type)
						 :AB(n, a, l) {
						 
						 string tmp;
						 string MobileBG = "888", MobileDE = "177";
						 string StaticBG = "00359", StaticDE = "0049";
						 
						 // Adding pre-dial stuff for the numbers(for convenience)
						 if(l == "Bulgaria")
								 if(type == 1)
											   tmp = StaticBG + MobileBG;
								 else
											   tmp = StaticBG;
						 if(l == "Germany")
								 if(type == 1) …
freemind 0 Junior Poster in Training

Hello Freemind:

I took a look at your code and actually attempted to run it in an empty default Visual Studio 6 project. It didn't compile but with different errors. The errors I recieved were around the 'add' function as well however.

Anyhow, with only a minor change I was able to compile and run your program. All I did was change the following three lines to use the base 'Worker' class instead of the derivied 'DepBoss' class: (each bold line replaces the line above it)

#include <iostream>
#include <string>
#include <list>
using namespace std; 
class Worker {
	 protected:
			 string fname, lname;
			 string address;
			 unsigned number;
	 public:
			 //inline virtual void add(DepBoss* new_boss, list<Worker*>& M) = 0;
			 [b]inline virtual void add(Worker* new_boss, list<Worker*>& M) = 0;[/b]
			 inline virtual void print(void) {
					 cout << " Name: " << fname << " " << lname;
					 cout << " Address: " << address;
					 cout << " Number: " << number;
			 }
			 Worker(string fn, string ln, string addr, unsigned n)
						 :fname((string)fn), lname((string)ln), address((string)addr) {
					if(n < 0)
						 throw "Scheisse in Worker Constructor!";
					else
						 number = n;
			 };
			 virtual ~Worker(){};
};
class DepBoss : public Worker {
	 private:
			 short level;
			 int podchineni;
	 public:
			 //inline virtual void add(DepBoss* new_boss, list<Worker*>& M);
			 [b]inline virtual void add(Worker* new_boss, list<Worker*>& M);[/b]
			 inline virtual void print(void);
			 DepBoss(string fn, string ln, string addr, unsigned n, short lvl, int pod)
							:Worker(fn, ln, addr, n) {
 
					 if(lvl < 0 && lvl > 5)
							throw "Scheisse in DepBoss Constructor(lvl)";
					 else
							level = lvl;
					 if(pod < …
freemind 0 Junior Poster in Training

Hi to everybody! Here I paste some simple exercise code that I wrote. The errors are pasted from the compiler log at the end of the source code. The add() function looks ok to me and I can't understand what the compiler wants from me :o Thanks!

#include <iostream>
#include <string>
#include <list>
using namespace std; 
class Worker {
	  protected:
			  string fname, lname;
			  string address;
			  unsigned number;
	  public:
			 inline virtual void add(DepBoss* new_boss, list<Worker*>& M) = 0;
			 inline virtual void print(void) {
					 cout << " Name: " << fname << " " << lname;
					 cout << " Address: " << address;
					 cout << " Number: " << number;
			 }
			 Worker(string fn, string ln, string addr, unsigned n)
						   :fname((string)fn), lname((string)ln), address((string)addr) {
					if(n < 0)
						 throw "Scheisse in Worker Constructor!";
					else
						 number = n;
			 };
			 virtual ~Worker(){};
};
class DepBoss : public Worker {
	  private:
			  short level;
			  int   podchineni;
	  public:
			 inline virtual void add(DepBoss* new_boss, list<Worker*>& M);
			 inline virtual void print(void);
			 DepBoss(string fn, string ln, string addr, unsigned n, short lvl, int pod)
							:Worker(fn, ln, addr, n) {
							
					 if(lvl < 0 && lvl > 5)
							throw "Scheisse in DepBoss Constructor(lvl)";
					 else
							level = lvl;
					 if(pod < 0 && pod > 100)
							throw "Scheisse in DepBoss Constructor(pod)";
					 else
							podchineni = pod;
			 };
			 virtual ~DepBoss(){};
};
inline void DepBoss::add(DepBoss* new_boss, list<Worker*>& M) {
			   M.push_front(new_boss);
}
void DepBoss::print(void) {
	 cout << " DepBosses:" << endl;
	 Worker::print();
	 cout << "\n Level of clearance: " << level;
	 cout << "\n Number of podchineni: " << …
freemind 0 Junior Poster in Training

Try to simplify your algorithms. Remember that you can combine loop types. This is often useful ;) . Also don't forget the code tags when you post code, because with them it's much more readable. One possible solution I paste below. Enjoy.

#include <iostream>

using namespace std;

int main(void)
{
    short count=5;
    
    while(count) {
                 for(int i=count; i!=0; i--)
                         cout<<'*';
                 cout << endl;
                 --count;
    }
    
    cout << endl;
    count = 1;
    
    while(count < 6) {
                for(short i=0;i!=count;i++) 
                        cout << '*';
                
                cout << endl;
                ++count;
    }
    
    return 0;
}
freemind 0 Junior Poster in Training
#include <iostream>
#include <string>

using namespace std;

class weather {
      private:
              int day;
              int month;
              int year;
              int temp;
              int humid;
              string condition;
              void leapyear(int);
      public:
             weather(int a=1,int b=99,int c=54,int d=100,int e=33,string= "Elie"); //Problem
             //~weather();
             void setall(int,int,int,int,int);
             int get_day();
             int get_month();
             int get_year();
             int get_temp(int);
             int get_humid();
             void print();
             void get_condition();
};




weather::weather(int x,int y,int z,int t,int h,string k)
        :condition(k)
{
    setall(x,y,z,t,h);
};
//weather::~weather() { delete condition;};

void weather::setall(int a,int b,int c,int d,int e)
{

     if (a<1 ||a>31)//day
         day=1;
     else 
         day=a;

     if (b<1 || b>12)//month
         month=1;
     else
         month=b;
         
     if(c<1900||c>2005)//year
         year=2000;
     else 
         year=c;

     if (d<60||d>60)//temp
        temp=20;
     else 
        temp=d;

     if (e<0||e>100)//humid
        humid=55;
     else
        humid=e;

     //condition=new char[strlen(f)+1];
     //assert (condition!=0);

}

int weather::get_day() {return day;};

int weather::get_month() {return month;};

int weather::get_year() {return year;};

int weather::get_temp(int t)
{ t=0;
  t=((9/5)*temp)+32;
  return t;
}

int weather::get_humid() {return humid;};


void weather::leapyear(int a)
{
 a=year;

 if (a%4==0 && a%100!=0)
    cout<<"This is a leap year"<<endl;
 else
    cout<<"This is not a leap year"<<endl;
}


void weather::print()
{
cout<<"On the: "<<day<<"/"<<month<<"/"<<year<<endl;
cout<<"-------------------------------------------------------"<<endl;
cout<<"Temperature is: "<<temp<<endl;
cout<<"Humidity (in %) is: "<<humid<<endl;
cout<<"Condition is "<<condition<<endl;
}





void weather::get_condition() { cout<<condition;};

int main()
{
 weather a;

 a.print();

 cin.get();
}

The errors:

1. When you assign values by default you have to either provide variable names or default initializers (see above).
2. The setall() function is unnecessary, all of it's body belongs to the class initializer function.
3. Since you assign a string value for condition and you're using C++ you can omit encountering C-style strings. Furthermore, since you assing value …