|
What's the difference between upcasting and downcasting?
|
|
|
|
|
Symfund wrote: What's the difference between upcasting and downcasting?
I am sorry but,I didn't get how this question answers my question?
|
|
|
|
|
And what are the differences between Bose-Einstein and Dirac-Fermi statistics?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Syntax Error: WOW! Chinglish! I am not a native English speaker.
|
|
|
|
|
Rahul Vaishnav wrote: d.Show();
The error is because the compiler do not know which Show() function it should call. Show() of Base1 or Base2. Actually which one do you want to call?
You have to tell the compiler which one excatly. like
d.Base1::Show();
or
d.Base2::Show();
|
|
|
|
|
|
Why do you need such multiple inheritance?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all
I developed an application using MFc and oracle.
The mFC transactions will be update in to oracle DB.
The app exe works fine in my PC, where as if i run on other pc's, it shows that it requires "Oracle Client".
Is ther any solution to run the exe without installing the oracle client.
|
|
|
|
|
|
This in no way answers his question. And what has his question got with platform neutrality ?
modified on Monday, November 16, 2009 11:07 AM
|
|
|
|
|
Hi...
i have a text file. Its size is more than 400000 bytes.
i need to store the file into single CString or char variable... Because i have to compare some variable, delete.
How can i store?
Thanks...
G.Paulraj
|
|
|
|
|
You to use CStringArray class, Just refer [^].
Since it is a array, you can store each line as a single array content.
You can do string manipulation in it easily.
Величие не Бога может быть недооценена.
|
|
|
|
|
|
what is wrong with my code it's kicking me in the head right now and if a kind soul could help me out i would be very grateful, thanks.
here is the goal:
Use a one dimensional array to solve the following problem. Read in 20 numbers,
each of which is between 10 and 100, inclusive. As each number is read, print it only if it
is not a duplicate of a number already read. Provide for the “worst case” in which all 20
numbers are different. Use the smallest possible array to solve this problem.Well,
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
#include <limits>
const int x = 20;
using namespace std;
int main()
{
int i = 0;
int toss = 0;
int count=0;
int population[20];
int num=0;
bool duplicate = false;
while(1)
{
for (int j = 0; j < x; j++)
{
srand(time(NULL));
num = rand()%90+11;
if (num == population[j])
{
duplicate = true;
toss++;
}
if (!duplicate)
{
population[j] = num;
count++;
}
}
for (int ii = 0; ii <= count; ii++)
{
cout << population[ii]<<" ";
}
cin.clear();
cin.get();
}
}
|
|
|
|
|
i think you need to re-think the problem.
here's a hint: the population array is going to start out with 0 items in it. after the first number read, it will have one item in it. after the second, it can have one or two. after the third, one, two or three. you need to keep track.
here's another hint: you're going to have two loops: one going from 0-19, to read the numbers, and another, inside the first, going from 0-N, where N is the number of items you've read and stored.
|
|
|
|
|
I turned in my assignment, but it wasn't right, so i lost some points, i was wondering if you could give an example on how to do this the right way? i apologize for asking, but my professor is very hard to understand due to the fact he is not a native speaker of English so mush of what i do know is self taught.
|
|
|
|
|
roughly, and in pseudo-code:
int storage[20]
int numStored = 0
loop 0 to 20, i
int newVal = read_a_value;
bFound = false
loop 0 to numStored
if storage[i] = newVal
bFound = true
break
.
if not bFound and numStored < 20
storage[numStored] = newVal
numStored = numStored + 1
.
|
|
|
|
|
Thanks Chris for taking your valuable time and helping me out, i really want to learn c++ and plan to take OOP next semester. so far my grades are in the low 90's and don't want to blow it towards the end of this semester.
dose all this belong in the same for loop? i am not sure what you are
saying in "read a value" could this be what you are
saying, "newVal = read_a_value[i];" or is
this it "newVal = rand()%91+10;"
how do i implement "see if you've already read that number" if after the
2nd number i will need to see if the previous number has been read and
chick if it's a duplicate. and each time a new number is generated it
must be checked to the others to see if its already there. i am having
a hard time visualizing the logic and i really do appreciate your time
to help me with this.
for loop 0 to 20, i
{
// read a value
int newVal = read_a_value;
// see if you've already read that value
bFound = false
loop 0 to numStored
if storage[i] = newVal
bFound = true
break
}
|
|
|
|
|
Omegaclass wrote: dose all this belong in the same for loop?
you'll have two loops. one inside the other.
Omegaclass wrote: i am not sure what you are saying in "read a value"
that's where you get the next input. your original msg says "Read in 20 numbers,
each of which is between 10 and 100, inclusive." so, if the test data is coming from a file, you'll need to open that file then read each number one at a time. or, if it's coming from the keyboard, or from stdin, or cin, etc..
rand() will work for testing, i guess. but that seems like a strange assignment. i know when i would get assignment like this, the instructor would have a set of data files that he'd send into the program, to make sure the app was doing what it was supposed to on known input.
Omegaclass wrote: how do i implement "see if you've already read that number" if after the 2nd number i will need to see if the previous number has been read and chick if it's a duplicate.
the previous number will be in the storage array - if it was duplicate, it was already there; if it was a new one, then you will have added it. so, you just need to loop through the items in the storage array and compare each one to the new value.
|
|
|
|
|
Thank you Chris i get it now. i appreciate your time. this road i am on learning C++ has not been easy, but it is interesting.
|
|
|
|
|
I seem to have an abundancy of questions at this time of year.
Anyways, I have a CreateRemoteThread hook that refuses to work. Here's the code:
HANDLE WINAPI MyCreateRemoteThread(HANDLE hProcess,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter,
DWORD dwCreationFlags,
LPDWORD lpThreadId)
{
if (GetpIDFromHandle(hProcess)==SelfpID){
SetLastError(ERROR_ACCESS_DENIED);
return NULL;
}
else {
}
This format seems to work for every other function I've thought of so far (the ones in KERNEL32.DLL, at least), but it doesn't work for CreateRemoteThread. Sure, the hook is reached and if another process is trying to create a thread in my process's context the SetLastError is executed, but then the calling process crashes. I thought it was a problem with the calling process at first (I wrote one just to test), so I took another program that uses CreateRemoteThread and it crashed too.
Is there anything wrong with my code? Thanks in advance.
EDIT: Clarification - GetpIDFromHandle returns the process ID given a process handle (this works perfectly fine) and SelfpID is a global variable containing the self process ID.
modified on Sunday, November 15, 2009 11:34 PM
|
|
|
|
|
hxhl95 wrote: ure, the hook is reached and if another process is trying to create a thread in my process's context
How is that possible? If you are installing a hook for this api in your process, the hook function will only be called if you call CreateRemoteThread() from your process. If some other process calls CreateRemoteThread to your process context, there is no way the above API to execute...isnt it?
|
|
|
|
|
IAT hooking. And unless I'm very much mistaken, it's working.
|
|
|
|
|
hxhl95 wrote: it's working.
Let me clarify your question
Process A
Installs a hook for the API CreateRemoteThread() in its process context.
Process B
Try to create a remote thread in "Process A". At this time you are telling that the hook function you installed is getting executed?????
|
|
|
|
|
Process A:
Installs a system-wide hook for CreateRemoteThread()
Process B:
Calls CreateRemoteThread in "Process A". My installed hook function gets executed, but returning NULL causes Process B to crash. Any other calls to CreateRemoteThread that don't involve Process A are fine.
|
|
|
|