|
which is called pass by reference. we can pass arguments in two type
1. pass by value
2. pass by reference
if we use pass by reference same location is passed to functions. no copying is occured. so any changes made is also reflect in original variable. so use const for to provide unexpected changing.
|
|
|
|
|
|
A constructor is a class member function in C++ and C# that has the same name as the class itself.
The main purpose of the constructor is to initialize all member variables when an object of a said class is created. (Resources acquired such as memory or open files are typically released in the class destructor).
Constructor are automatically invoked when the object is created. Constructor doesn't have any return type, including return voids.
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:39am.
|
|
|
|
|
i got this error message in my program :
1>Reservation.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Reservation::ID_sn(void)" (?ID_sn@Reservation@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Reservation::getReservationNumber(void)" (?getReservationNumber@Reservation@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
and this is the program it contain 2 header files and their cpp file plus the main file
Passenger . h
<pre>#ifndef PASSENGER_H //to avoid redefinition errors
#define PASSENGER_H
#include <iostream>
#include<string>
using namespace std;
class Passenger {
public:
Passenger();
Passenger(string,string,long);
void setPassengerName(string);
void setPassportNumber(string);
void setContactNumber(long);
string getPassengerName();
string getPassportNumber();
long getContactNumber();
void printDetails();
private:
string passengerName;
string passportNumber;
long contactNumber;
};
#endif
Passenger . cpp
<pre>#include <iostream>
#include "Passenger.h"
using namespace std;
Passenger::Passenger(string a="",string b="",long c=0)
{
setPassengerName(a);
setPassportNumber(b);
setContactNumber(c);
}
void Passenger::setPassengerName(string Pname)
{
passengerName=Pname;
}
void Passenger::setPassportNumber(string Pnum)
{
passportNumber=Pnum;
}
void Passenger::setContactNumber(long Cnum)
{
contactNumber=Cnum;
}
string Passenger::getPassengerName()
{
return passengerName;
}
string Passenger::getPassportNumber()
{
return passportNumber;
}
long Passenger::getContactNumber()
{
return contactNumber;
}
void Passenger::printDetails()
{
cout<<"passenger name: "<<getPassengerName()<<"\npassenger Passport Number: "<<getPassportNumber()<<
"\npassenger contact number: "<<getContactNumber()<<"\n\n";
}
Reservation . h
<pre>#ifndef RESERVATION_H_ //to avoid redefinition errors
#define RESERVATION_H_
#include <iostream>
#include <string>
#include "Passenger.h"
using namespace std;
class Reservation{
private:
static int sn;
const string ID;
bool smokerSeat;
Passenger passenger;
public:
Reservation(string psngrName, long psngrPhone, string psngrPassport, bool smoke);
Reservation(Passenger& psngr, bool smoke);
Passenger getPassenger();
bool isSmoker();
string getReservationNumber();
void printDetails();
string ID_sn();
};
#endif /*RESERVATION_H_*/
main .cpp
<pre>#include <iostream>
#include "Passenger.h"
#include "reservation.h"
int main()
{
Passenger passenger1("aar","k9",23596);
Passenger *passengerPtr=&passenger1;
passengerPtr->printDetails();
Reservation reservation("aarr",566,"t77",0);
Reservation *reservationPtr=&reservation;
reservationPtr->printDetails();
system("PAUSE");
}
Im a beginner in programming and that's problem make me really confused
** i think the problem in the Reservation.cpp
Because when i test the other file's it was working but after i added the implementation for the reservation header this problem was appeared
modified 14-Dec-12 7:41am.
|
|
|
|
|
In reservation.h the function ID_sn() is declared. But there is no implementation for this function. In Reservation::getPassenger() you are using this function. Because you are trying to assign a string value to this function, I assume that you wanted to declare a member variable rather a function in reservation.h :
string ID_sn;
|
|
|
|
|
thanks a lot its work
|
|
|
|
|
The error message tells you what the problem is, but it can be hard to understand when you're not used to all the extra template information it spews out.
What it means is that you used a function called "ID_sn" in the getReservationNumber function, both of them are members of the Reservation class, and the linker couldn't find a definition for the ID_sn function.
|
|
|
|
|
thank you i understand it now
|
|
|
|
|
for so long i been trying to learn c++ on my own , but i never got to finish the beginner phase because i always get the feeling im not on the right track ,i always get confused about many stuff like native c++ visual c++ etc...
my goal short term goal is to be able to deal with packets you know decryption\encryption in order to make packet based frame work for online game in other word a bot and of course i wanna go deep into c++ i really enjoy programming but i want to reach goal before i get so bored learning the wrong stuff ,today i decided to ask for help i wanna save time and effort so those of you who knows what should i learn to reach my goal please guide me , tell me what books to read ,what aspects of c++ should i consider as my fundamental information regarding my goal , i dont wanna learn unnecessary information ,dont get me wrong i fully understand that in order to get there i need to learn the very basics but what i want is simply a plan so that i dont get lost or bored in the middle.
thanks in advance
|
|
|
|
|
If you get bored learning the basics then you are never going to get to the advanced parts. You need to understand the basic aspects of the language completely if you wish to succeed as a developer. There is no substitute for study and practice.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
i dont get bored learning the basics i get bored after ,when i find my self lost , i wanna know what's next , as far as i know basics are the common ground and after you learn them you move to a next phase depending on what you wanna do , for example you wanna be game developer you study certain things , things that are different from someone wanna be windows forms developer ,so my question is what do i have to learn after i finish the basics phase? and thanks for your reply.
|
|
|
|
|
ziuss2 wrote: what do i have to learn after i finish the basics phase? That depends entirely on what you want to do. If you want to develop desktop applications then you can start at Windows Desktop App Development[^]. If you want to move into web programming then try Web Development[^], etc. The information is all out there, but you have to go and study it for yourself.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Good. C++ is very powerfull programming language. To study c++ you should start from it's basic knwoledge.
If you are experts in it's basic concepts then you can develop a good c++ knwoledge very fast. i can sujest a very good c++ books that i have been ever read.
1. Effective C++ Third Edition 55 Specific Ways to Improve Your Programs and Designs - by Scott Meyers
This is a very good book from the view of beginers, developers. You can download it pdf by name searching in google.
2. If you want to study MFC with visual c++ then i can sujjest
Programming windows with MFC - Jeff Prosise
This is also a very good book.
|
|
|
|
|
thanks sajeesh.c i will take your book suggestions to consideration and check them out , but still guys you dont get what im trying to do anyways i think im on my own seems that no one sees my realy question which is about what to learn if i wanna make packet base programs for games "bot"
|
|
|
|
|
ziuss2 wrote: what to learn if i wanna make packet base programs for games "bot" Well, the first thing you need to do is explain exactly what you mean by "packet base programs" and "games "bot"".
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
oh man ,so all this time you were answering me for question you do not understand
well any online game uses internet connection and some sort of security such as bluefish protocol , packet based program (bot program)is a third-party program that read encrypted data between the game client and the game server then parse the data analyze it then sends the proper data (client side) to game server , if you are wondering why would someone needs a program like this ,well its for games that takes long to level up ,there is so many other sort of bot programs like msn bots that spam porn sites etc... all of theme follow the same concept ,now let me ask again , what should i learn to master data encryption\decryption ,socket and any other thing would help me reach my goal which is making a bot program
|
|
|
|
|
ziuss2 wrote: what should i learn to master data encryption\decryption ,socket and any other thing Enryption/decryption is discussed here on MSDN[^]. There is lots of information to be found on sockets through Google[^]. No doubt you can do some of the other searches for yourself.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I think your short term goal is way too advanced!!!
You have set a goal that makes it impossible to learn in a good manner; packet dealing for online games and encryption/decryption are really advanced topics!!!
If your goal is to do an online game, start by designing a simpler off-line version of your game, set up all the game mechanics, graphics/sound/behaviours/level design so that you will have a better/good understanding of the language.
When doing this, have a proper plan; split your project into small chunks; make it in such a way that each chunk improves your learning of the previous chunks.
good luck.
Nihil obstat
|
|
|
|
|
with due all respect to all your replies ,but seems that no one actually know what im talking about im not sure is it due to the fact that my first language isnt English so there is a chance i didnt explain my question enough or you guys just like to answer any question disregarding understanding the question , so one again i will try to explain what im trying to achieve , pick any online game you know let's say wow for example a bot for wow would be a third-party program that play the game for you according to certain configuration ,how dose this program work? well i know the logic behind such a program fist you need to investigate the game find the game packet encryption protocol once you know that you will understand what every packet data for , then you start of creating algorithms to do certain action with these packets for example localizing a monster name HP etc... so what im looking for is how to know how to deal with packet on these terms ,its hard to explain the idea specially if you dont know what is a BOT program is!! i already have some source code bots for some games but i dont understand most of it this is why i need to know what should i learn before i can understand this codes anyway i think it will try to ask the same question on some other forum
|
|
|
|
|
Are you looking for code to do "raw packet sniffing" ?
Once you are able to identify the game's packets, you can then try to reverse-engineer the content ( and this is hard).
Anyway,
I still feel that you are getting into something that is WAY over your current coding experience and expertise.
Good luck.
Nihil obstat
|
|
|
|
|
yes it is way way over my current coding experience which is zero in c++ ,and yes raw packet sniffing/editing is big part of what i wanna do,i just need guide lines how to achieve that ,im willing to put time and effort ,but i just don't know what should i learn beside basic stuff , i don't wanna consume time learning things that wouldn't help me about that matter
|
|
|
|
|
Give up. You haven't got a hope in hell.
|
|
|
|
|
Hi ziuss2!
It is true what our peers above says. You need to fully grasp the fundamentals. And sometimes programming can be tedious and drawn out. I would recommend you sign up for a class at your local school or maybe even take an evening class. Maybe a structured (classroom) environment will help you focus and keep on track.
Best of Luck!
With Kind Regards,
Live Support Software for Business
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:40am.
|
|
|
|
|
hi ...
i need to develop an windows application in c# to communicate in Lan in windows 7 environment . i need ideas to develop this.
thanks
|
|
|
|
|
Try the C# forum, and also explain in more detail what your problem is.
One of these days I'm going to think of a really clever signature.
|
|
|
|