|
<font color=green>
<font color=blue>void</font> ShowBits(<font color=blue>int</font> iData) {
std::string strResult(<font color=gray>""</font>);
<font color=blue>int</font> iNbBits = <font color=blue>sizeof</font>(iData) * 8;
<font color=blue>for</font> (<font color=blue>int</font> i = 0; i < iNbBits; i++) {
<font color=green>
strResult = std::string( (<font color=blue>char</font>)(((iData >> i) & 0x00000001) + <font color=gray>'0'</font>) ) +
strResult;
}
std::cout << strResult;
}
it's my goodness day...
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 10:49 Tuesday 13th September, 2005
|
|
|
|
|
THANK YOU VERY MUCH FOR THE HELP AND REPLY
Regards
cnu...
|
|
|
|
|
toxcct wrote:
it's my goodness day...
Yes, I can see that . I was too lazy
|
|
|
|
|
but i'm sad to see that the only i get is sometimes get voted down when i make an effort to produce a godd and well presented answer to a post...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Sorry for the double post I think this belongs here!!
I pulled some code off of this site to create a nice clean looking LCD. It is called StaticCounter (Nice LCD display)
The code by itself seems to work fine however when I tried to integrate it with my current project or a brand new project I get the error.
C1010 Unexpected end of file while looking for precompled header directive.
I did some searching on both google and code project and found a couple things about stdafx.h no being included in the project, but sadly it has been a part of my MFC project since the beginning.
I tried to email the Author: Jason Hattingh but the code is rather old and I didn’t really expect help but it was worth a shot.
I’m starting to wonder if it is the difference in the fact that the project was not created in the .NET environment, but I have never had this problem in the past.
What I have done to eliminate Problems:
1.Created a brand new project with the MFC wizard.
2.Made it Dialog based.
3.Compliled the project to make sure it was working
3.Added the "proveded files" to the new project
4.Made sure necessary includes where put in place.
5.Compiled and received the C1010 error.
Any help would be greatly appreciated.
-Chris
|
|
|
|
|
cjbaltar wrote:
I did some searching on both google and code project and found a couple things about stdafx.h no being included in the project, but sadly it has been a part of my MFC project since the beginning.
The problem is that stdafx.h is not being included by the code you've added to your project. You can either add it before all other includes in your new files, or change your project to automatically use precompiled headers ( which means it will only for files that include stdafx.h )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian,
Thank you oooooo thank you I just noticed that 1 file yes only 1 file had the stdafx.h 2nd line from the top of other includes.... and in deed it was the problem...
I cant tell you how much time I spent on something soooo basic. I will have to send you my finished code when it is entirely done!!
(we need a jumping for JOY smiley face) cuz thats me right about now!
Best Regards
-Chris
|
|
|
|
|
No worries, glad to help. That one caught me out once upon a time, as well. It's not exactly clear anywhere.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
This is repost If you have seen it, but as I getting clearer as to what the questions this few lines of code have presented, I feel it is necessary to repost it because there's something that I knew the answer which I want to share and of course some I don't know and that's for you.
#include <iostream>
using namespace std;
class A
{
int i;
public:
A(int ii = 0) : i (ii){}
friend A operator+(A& left, A& right)
{
return A(left.i + right.i);
}
friend A operator-(A& left, A& right)
{
return A(left.i - right.i);
}
friend ostream& operator << (ostream& os, A a);
};
ostream& operator << (ostream& os, A a)
{
return os << a.i << endl;
}
int main()
{
A a(1), b(2), c(3);
cout << (a + b);
cout << (a - b);
getchar();
}
First of all I'm under VC++ 6.0
Those questions surround the code above are characterized by the following debug error messages:
1. "fatal error C1001: INTERNAL COMPILER ERROR".
2. "'i' : cannot access private member declared in class 'A'"
3. "'operator <<' is ambiguous"
The one of the resolution for the first one is operator foreward declaration which is pretty clear.
But I'm not clear with the 2, 3. For 3, the following statement is my guess and probably wildest guess, since that's the most logical one I can think of, correct me if I'm wrong. It seems once you move the definition for friend operator "<<" out of the class then the Koenig lookup was applied, because it is an unqualified the function, that was what the theory says(function at file scope fit into the unqualified category?). According to the theory cout << A bring the namespace "class A" into the list for lookup and it's ambiguous against the operator "<<" in <iostream> since "using namespace std" is introduced here? bur for the 2 I don't know why the compiler see friend operator "<<" as a function which has nothing to do with class A, Is there correlation exists between question 2 and 3?
Here the right implementation, at least at the compiler perspective
#include <iostream>
using namespace std;
class A;
A operator +(A& left, A& right);
A operator -(A& left, A& right);class A
{
int i;
public:
A(int ii = 0) : i (ii){}
friend A operator+(A& left, A& right)
{
return A(left.i + right.i);
}
friend A operator-(A& left, A& right)
{
return A(left.i - right.i);
}
friend ostream& operator << (ostream& os, A a);
{
return os << a.i << endl;
}};
int main()
{
A a(1), b(2), c(3);
cout << (a + b);
cout << (a - b);
getchar();
}
Probably I'll go to bed with unsolved questions in mind, cuz here's late at night
|
|
|
|
|
LiYS wrote:
'operator <<' is ambiguous"
This means you're passing an unknown type to <<, and it can't work out what to cast it to in order to proceed. It generally means it has one or more options.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Have nothing to do with Keonig lookup?
|
|
|
|
|
Yeah, that's also possible. I'd not have expected that error though, I don't think.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i'm working on a mac machine using CodeWarrior. first when i was compiling my program, it gave me an error that said that the header "net/if.h" couldn't be opened. so i changed my projects settings to include the header file path in the user access paths. now when i compile, it gives me the following error from inside the header file:
illegal use of incomplete struct/union/class "struct if_data". the error is traced to a line in the header file that says: struct if_data if_data (if_data is defined in another header, if_var.h which is included in if.h). Why would there be an error inside the header file? and how can i fix this problem?
Rola
|
|
|
|
|
Hello everybody?
I am trying to know how I can detect changes in data streams.
But I don’t have any practice this field.
I found 1 paper and read it. But I didn’t understand fluently it. (http://www.cs.technion.ac.il/~shai/vldb04.pdf)
If you have any idea about detecting changes in data streams, can you help me?
Also can you explain to me algorithm that presented paper?
What is distance anything?
My e-mail address is u_bulga@yahoo.com.
Thank you so much for your help.
Thank you
|
|
|
|
|
i face problem in insert data from text file to mysql database,when the program finish read a line of a text file,it should insert data into database.
How can i make the program to insert data into database once read a line from text file?
Below is my code:
-----------------------------------------------
void CXXXDlg::OnButtonInsert()
{
// TODO: Add your control notification handler code here
CStandardDB db;
FILE* pFile = fopen("c:\\XXX.txt","r");
log_standard logRead;
while (!feof(pFile)) {
if(!searchfile(logRead.strLogdate,pFile,'\t'))
break;
if(!searchfile(logRead.strLogtime,pFile,'\n'))
break;
insertdb(&logRead);//after finish read a line,call insert data
}
//insertdb(&logRead);//success insert last line of data if call insert data here
}
void CXXDlg::insertdb( logfile * pLog)
{
CDatabase myDb;
myDb.Open(NULL,FALSE,FALSE,"ODBC;DSN=standard");
CODBCRecordset rs(&myDb);
CString strQuery="";
strQuery.Format("insert into standard (logdate,logtime,name) values (\'%s\',\'%s\',\'%s\')",
pLog->strLogdate,pLog->strLogtime,pLog->strName);
//AfxMessageBox(strQuery);
myDb.ExecuteSQL(strQuery);
}
|
|
|
|
|
I'm having trouble trying to do one on the implementation files of my project. can you plz help... i will attach the appropriate header file/s and .cpp files which I have completed, yet however that is one .cpp which is partially completed, can you really help with the definition of the member functions. The partially completed file is called EmployeeDatabase_template.cpp. i included the source code below for you to look at. plz help with definition of these member functions
<pre>
#include "EmployeeDatabase.h"
#include <vector>
using namespace std;
EmployeeDatabase::EmployeeDatabase()
{ // Complete code.
size = 0;
}
void EmployeeDatabase::getEids(vector <int>&ids)
{ // Complete code.
}
string EmployeeDatabase::getName(int employeeID)
{// Complete code.
}
double EmployeeDatabase::getShoeSize(int employeeID)
{// Complete code.
}
void EmployeeDatabase::makePerson(string employeeName, int employeeID, double employeeShoeSize)
{//complete code.
}
int EmployeeDatabase::getSize()
{// Complete code.
return size;
}
</pre>
here is the appropriate specification files(header files).
this is EmployeeDatabase.h
<pre>
// A EmployeeDatabase consists of a vector of Persons;
// methods are supplied to retrieve all the employee IDs and
// to query the database for employee names and shoesizes using
// the corresponding employee id.
#include "Person.h"
#include <vector>
using namespace std;
#ifndef EmployeeDatabase_H
#define EmployeeDatabase_H
class EmployeeDatabase{
public:
EmployeeDatabase();
// Constructor:
// Makes an instance of an EmployeeDatabase containing no data.
void getEids(vector <int>& ids);
// Returns a vector of all the employee ids in the vector people.
string getName(int employeeID);
// Returns the name of the Person with eid equal to employeeID.
double getShoeSize(int employeeID);
// Returns the shoesize of the Person with eid equal to employeeID.
void makePerson(string employeeName, int employeeID, double employeeShoeSize);
// Creates a new instance of Person using the input data
// and adds it to the vector people.
int getSize();
// Returns the number of Persons stored.
private:
// The database is vector of Persons.
vector <Person> people;
int size; // The number of Persons in the database.
};
#endif //EmployeeDatabase_H
</pre>
This is Person.h
<pre>
// A Person consists of the name, the employee ID and the shoe size.
// Methods are supplied to retrieve each of the three data items.
using namespace std;
#include<string>
#ifndef Person_H
#define Person_H
class Person{
public:
Person(); // Default constructor.
Person(string personName, int personId, double personShoeSize);
// Constructor:
// Makes an instance of a person with the
// given data.
string getName();
// Returns the name of the Person.
int getEid();
// Returns the employer ID of the Person.
double getShoeSize();
// Returns the shoesize of the Person.
private:
string name; // The employee's name.
int eid; // The employee's ID.
double shoeSize; // The employee's shoesize.
};
#endif
</pre>
PLZ CAN YOU HELP ME WITH THE FIRST BIT OF CODE THE OTHER TWO ARE THE HEADER FILES. I JUST CANT FIGURE OUT HOW TO DEFINE SOME OF THE MEMBER FUNCTIONS.
|
|
|
|
|
You need to create a vector of employees, then the makePerson method should create a person from that data, and push it onto the vector. Then you can return the vector, or search it for the data that the other methods require. Have you used a vector before ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
no I have very limited knowledge on vectors. I know the push back and pop stack functions but vectors, I'am in the process of learning. However could you possibly show in first bit of code, in which I have the member functions undefined,(place where it says complete code). I have created a application test program, however, i need first to define those un-completed member functions. CAN U PLZ make adjustments to the code given.. plz help.. THANKS FOR THE SHARP RELPY
|
|
|
|
|
in the header file you need
vector<person> m_Staff;
void EmployeeDatabase::getEids(vector <int>&ids)
{ // Complete code.
ids = m_Staff;
}
void EmployeeDatabase::makePerson(string employeeName, int employeeID, double employeeShoeSize)
{//complete code.
Person p(employeeName, employeeID, employeeShoeSize); // this assumes a class called person with this constructor signature
m_Staff.push_back(p);
}
Now, for your search functions, do you want to do something like :
std::vector<person>::iterator it = m_Staff.begin();
for (; it != m_Staff.end(); ++it)
{
Person p = *it; // You dereference an iterator to get the object.
// Check if this person has the data you're looking for, and if so, return it.
}
// return some default value for item not found.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello everyone!
OK, look:
http://www.sulfurmidis.com/error.jpg
That's part of what I get when I try to compile my code in DOSBox using this command:
gpp tfc.cpp
The problem is that the code compiles really well on both Windows and Linux... Is this a problem with DJGPP and DOSBox, or am I doing something wrong? I downloaded everything that the Zip Picker from DJGPP's site told me, and then I unzipped it to a directory, set the DJGPP environment variable to "C:\DJGPP\DJGPP.ENV" (I also tried with forward slashes) and added the Bin directory to my PATH. Do I have to do something else? What do I do at this point? Thanks! Everyone who answers gets a free caramel candy!
PS: What's the difference between the GPP and G++ commands?
Sulfurik K. Nosferathus (Darth_Sulfur)
www.SulfurMidis.com
www.SulfurSoft.tk
http://www.BeepXtreme.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
|
Wow, I never thought I'd have to post this question here but after digging around I'm not totally certain what the best approach is.
Essentially, I'd like to write something like kiwisyslogD without the UI. Essentially I just need to watch in/out traffic on a NIC and log whether it's TCP/UDP/Etc the port and remote IP. If it's a web request I want to get the URL. I've seen tons of different examples that use WinPCap, Network Packet Drivers, Etc. They seem to have a lot of other stuff I don't need. This is only going to log to a file. It will never have a user interface nor will it do anything other than what I've just described. I only need Windows support and if I cannot support all flavors then 2K/XP/2K3 will have to do. I have no need/reason to log the traffic on the network. Just in/out on the host machine's NIC.
If I didn't have to reference a 3rd partly library I'd prefer that. What are the ideas and where do I begin? I've programmed in C/C++ but not in this nature before.
- Rex
Some assembly required.
Code-frog System Architects, Inc.
-- modified at 21:25 Saturday 10th September, 2005
|
|
|
|
|
I wrote some program about polymorphism but it is giving runtime error.
what i observe is it is not calling type cat speak() function
#include <iostream>
#include <string>
#include <conio>
using namespace std;
class Pet
{
public:
Pet(){}
virtual ~Pet(){}
virtual void speak();
inline void breath()
{cout<<"\nGASP "<<endl;}
};
void Pet::speak()
{
cout<<"\nGROW! "<<endl;
}
class rat:public Pet
{
public:
rat(){}
~rat(){}
void speak();
};
void rat::speak()
{ cout<<"\nRat noise "<<endl;}
class cat:public Pet
{
public:
cat(){}
~cat(){}
void speak();
};
void cat::speak()
{
cout<<"\nMeaw "<<endl;
}
/*void chorus(Pet pet,Pet *ptr,Pet &refptr)
{
pet.speak();
ptr->speak();
refptr.speak();
}*/
#define MAXCAP 50
int main()
{
int quit=0;
int choice;
int toalno;
Pet *ptr[MAXCAP];
int i=0;
while(quit==0&&i<MAXCAP)
{
cout<<"\nEneter(0) for Quit"<<endl;
cout<<"\nEneter(1) for rat"<<endl;
cout<<"\nEneter(2) for cat"<<endl;
cin>>choice;
if(choice==0)
{quit=1;}
else if(choice==1)
{ ptr[i++]=new rat;}
else if(choice==2)
{ptr[i++]==new cat;}
else
{cout<<"\nINVALID ENTRY"<<endl;}
}
toalno=i;
for(i=0;i<toalno;i++)
{
ptr[i]->speak();
}
getch();
return 0;
}
Regards
cnu...
-- modified at 13:06 Saturday 10th September, 2005
|
|
|
|
|
mcnu wrote:
{ptr[i++]==new cat;}
Did you mean = ?
BTW, I threw this into a compiler to see what was wrong and found it right away. Your compiler should give you a warning for mistakes like this, mine did.
Christian Graus - Microsoft MVP - C++
-- modified at 18:33 Sunday 11th September, 2005
|
|
|
|
|
I got that .But my compiler didn`t give any warnings for this.i am using Borland C++ 5.0
sorry for the wasting of your valueble time and
THANKS FOR THE HELP
Regards
cnu...
|
|
|
|