|
To reiterate: you are either not including this file, or you are including it in the wrong place, or it does not define what you think it does. Or possibly you have two files with that name, and the wrong one is being included.
It would help if you posted some code, and the error you are getting.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
i guess the mistake, that you are doing is that, you are using double quoutes instead of angled brackets to include the the file.
kindly write #include<wincrypt.h> at the top of your .cpp file in which you using HCRYPTPROV. You should use Microsoft C compiler instead of Turbo C.
|
|
|
|
|
hi
i have used angle brackets to include th file Wincrypt.h in my file
and iam using VC++ for doing the project .. i hope that should be enough
i am not able complie the project
thanks ...
qrious
|
|
|
|
|
Hello all,
I'm a really new c++ programmer in the U.S. Navy. I'm trying to write an airline reservation program with a class list{} class flight{} and class passenger that has to read passengers and files from a file. I have no idea how to start this program. Any help would be appreciated. this is what I was given for it. Struct flight { int number; //flight number
char *from; //departure city
char *to //destination city
struct flight *next; // link to next flight
struct pass *pass //link to passengers
};
struct pass
{
char *first; //first name
char *last; // last name
char seat[4] //seat number
struct pass *pass; // link to passengers
struct header
{
struct flight *first;
struct flight *last;
int howmany; //howmany flights
Any help on getting started with the accessors and constructors I might need would help a lot. I did this school that I was made to do in a week and trying to learn all of c++ in a week is not easy. If anyone has any good ideas on a start or how I should go about doing this please help me.
Thanks
|
|
|
|
|
Hi there. If you need to read and write information from a file, you should read my articles on iostreams. Basically you #include<fstream> and then you can read and write files easily, and you could even set yourself up to read and write your custom structures with inserters and extractors ( this is not hard, I have an article on it here on CP ). Then you could do this:
pass myPass;
ifstream myFile("c:\\file.txt");
while (myFile.good())
{
myFile >> myPass;
// do something with the passenger
}
// the end.
It's a shame you need to use char *'s instead of strings. A struct is just a class whose default access is public, you should add constructors and destructors to the structs, the constructor should set the char *'s to null, and the destructors show call delete [] on them if they are not null.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I can change what is inside of my struct or I can even make it a class i'm not bound to do it that way. It was just an example set up for us. I just have trouble starting the program. I'm so new that I still look in books and try to get ideas but still struggling. Thanks for the advice I will definetly try to figure it all out.
|
|
|
|
|
sakota wrote:
I can change what is inside of my struct or I can even make it a class i'm not bound to do it that way.
In that case, absolutely make the strings strings instead of char *. so #include<string> and put using std::string at the top of your code. Then you can use the string class to handle string memory for you. Your only problem is if you use iostreams to read the file, you'll need to use getline to read strings, or otherwise reading will stop when the string has a space in it.
By all means, post your code as you go, and we'll be glad to help more.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Also the program has to have a menu that allows users to list flights (from a txt file called flights)
list passengers on a particular flight (from a txt file called pass)
add a passenger (add to a particular flight that is in the flight file)
and exit.
Making the menu is pretty much the only thing that I'm able to do pretty easily I think. Thank you all for the help.
it says that I will need at least these three classes
class list {} to be used by the flight class
class Flight {} a flight object for each flight
class Passenger {} a passenger Object for each passenger
Most of the people in this class are new at programming and have given up on this project already. We aren't graded on it we just are suggested to do it. I want to do it so I can gain the coding experience. It is hard to get ideas when you don't know where to start or what you should be looking at. We don't even have an instructor to ask we had to learn everything by a CBT online. This really sucks.
|
|
|
|
|
sakota wrote:
I want to do it so I can gain the coding experience. It is hard to get ideas when you don't know where to start or what you should be looking at. We don't even have an instructor to ask we had to learn everything by a CBT online. This really sucks.
It sounds like an advanced starting project, but it also sounds like you have the right attitude. Stick with it, you'll learn a lot from this project, and you can always ask more questions when you get stuck.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
alright i have done some things with this code now. i'm a bit confused now though. i have all my accessors and mutators and my constructors but i don't know how to implement the accessors and mutators that are pointers.
this is how it is setup
class Flight
{
private:
int number; // flight number
string from; // departure city
string to; // destination city
Flight *next; // link to next flight
Pass *pass; // link to passengers
public:
Flight(int fnum, string dept, string dest);
Flight();
Flight(const Flight & rhs);
Flight & Flight::operator=(const Flight & rhs);
~Flight();
void print() const;
int getnum() const;
string getdept() const;
string getdest() const;
Flight getnext() const;
Pass * getpass() const;
void setnum(int fnum);
void setdept(string dept);
void setdest(sting dest);
void setnext();
void setpass();
};
the ones i'm having troubles with are the void setnext(); and the void setpass(); Flight getnext() const; and the Pass * getpass() const;
I was told I had to have them but not sure how to implement them in my source file. I have everything else setup except for my print function and those four accessors and mutators. Any suggestions.
I have made a flight class that is shown here and a similar pass class and i also have to make a list class that I have no idea how to do yet. I have made the menu to select showing the flights adding passengers and listing passengers on a selected flight. I just have to figure out how to implement it all together. I'm taking baby steps. but getting there I think.
|
|
|
|
|
Why do you have to make a list class/linked list ? Is it an aim of the exercise ? I applaude the idea of you writing a list to know how they work, but C++ has one built in if you don't NEED to write one.
I'm not sure what you're asking, but if you have an object, you can get a pointer to it by putting & in front of it, and you can get an object from a pointer by putting * in front. If you make a copy of a pointer, both objects point to the same memory and so if you change one, the other also changes. This is called a shallow ( as opposed to deep ) copy. Like this:
Flight f;
Flight * pF = new Flight();
Flight * pF2 = pF; // now changes to one pointer changes both, as they are the same
pF = &f; // Now changes to f also change pF, but pF2 won't be changed
f = *pf2; // Now f and pF2 point to the same thing.
You'll see how if people start playing games with pointers, it's easy to lose track of memory you have allocated. This is what a memory leak is, the computer holds memory, thinking you're using it, and you've thrown away the details, so you can't do anything with it.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Private! You need a good book on STL. Read it, try your knowledge and repeat until you know it by heart. That way you don't have to meddle with lowlevel stuff such as keeping track of next pointers, and char*.
Straight C++ is to C++ with STL like an Ensign is to an Admiral.
--
Intellectualize my blackness[^]
|
|
|
|
|
Good advice, but if he's been given the structs, then he's bound to use the format they asked of him, surely ? It's pretty rare for any student to be taught the STL in my experience, they mostly learn C with classes, not C++.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
Before you start coding you should analyse every little detail. Some of those details are: user requirements, data used, classes to be used, member functions of the classes, relations between the classes and so on...
You should make a diagram of the details related to classes. See this[^] article for details about the diagram.
When you've done all the analysing, just implement all the classes. The only thing remaining is putting all together, but that should not be a problem if your design is right!
Good luck
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Is it possible to use the string class within another class? For example:
#include <string.h>
class x {
public:
method(); //... and so on
private:
string foo;
};
So far I've been getting errors when doing so, and have had to declare the strings outside of the class, which is not at all what I want to do. Any thoughts?
|
|
|
|
|
What errors are you getting ? I'd suggest they probably relate to the fact that I don't see 'using std::string;' anywhere in the above code. String lives in the std namespace, and needs to be scoped either when you use it ( std::string foo; ), or by a using statement to make it available to the global namespace.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
If I hava a class which has handle to a Mutex object as a static member such as:
class sharedClass{
public:
void accessSomeResource();
private:
someResourceType someResource;
static HANDLE hMutex;
}
...and I have mutliple threads instantiate there own sharedClass object.
Clearly, access to the resource is protected but what about the handle itself? Each thread will have access to the same static hMutex in an unsynchronized way.
The handle is not overwritten anyware. I'm only using it in the sycnchronization calls but could this be a problem??
-Alan
|
|
|
|
|
i didn't really understand ur issue... again please!
Don't try it, just do it!
|
|
|
|
|
when i include more than 1 user defined header file eg
#include "tcplib.h"
#include
#include
#include "big.h"
tcplib.h and big.h..... the second header file doesnt include in that it gives me errors saying its not included, any ideas on how to solve this? are you able to include more than one user defined header file?
also getting this warning:
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
|
|
|
|
|
Because you didn't check 'do not treat <'s as HTML tags', I cannot see what else you included. If stdafx.h is in there, it needs to be the FIRST thing you include, everything else after. I tend to include all the standard stuff first, then my own headers underneath. You can include as many as you want to.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Mr. Cully wrote:
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
Do exactly what it says. Add /NODEFAULTLIB:LIBC to your linker settings and the warning will go away..
John
|
|
|
|
|
i guess the problem you are facing is that, tcplib is a file already in use by the linker as default library. Thats why you are getting a message use "/NO DEFAULT" tag in you progam settings. My suggestion is to change the name of your user defined file, tcplib.
|
|
|
|
|
Hello, there,
I know there are several classes that can make the buttons in a dialog box become xp style. I'd like to know how I can do the same thing to the buttons in the MessageBox.
In other dialog box, I need to set the buttons to "Owner Drawer" and the subclass the button with other class that can actually draw the button. But in MessageBox, I don't know how to do something similar.
Any suggestion would be highly appreciated.
Thanks a lot.
Bin
|
|
|
|
|
Hello,
In my CChildFrame in PreCreateWindow I am removing the WS_MINIMIZEBOX and the WS_MAXIMIZEBOX (this is what I want) then in Activate Frame I force the view to Full size.. I only want the "X" close button to be displayed but when I force the view in to maximize it displays the restore down button... anyone know how to remove this button (I dont want to just disable it)?
Thanks,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hi,
I have a map<string,int>.I want to sort it on values(int).How do I do this?
Karteek
|
|
|
|