|
Thanks Davy. I think I've tried this... Now I'm getting a compile error. I'm using Visual Studio .net 2003 by the way.
/*
I'm trying to create my own class to store information about a person
in this example, an employee. This is just a test run to be able to
create a class, instantiate an aray of objects based on that class,
and update them as we need to input the record. This is just the first block of
a larger scope program.
*/
#using mscorlib.dll
using namespace System;
__gc class NameStorage //Starting the class definitions
{
public:
String* GetName() //GetName method to return a constructed name from inputed data
{
fullName = String::Copy(String::Concat(lastName,", ", firstName)); // Builds the full name string
return fullName; // using .Net String class methods
}
String* GetCompany()
{
return company; // Self explanatory
}
double GetSalary()
{
return salary; // Self explanatory
}
void SetFirstName(String* input)
{
firstName = String::Copy(input); // Following code inputs the data inputed
}
void SetLastName(String* input)
{
lastName = String::Copy(input);
}
void SetCompany(String* input)
{
company = String::Copy(input);
}
void SetSalary(double input)
{
salary = input;
}
private:
static String *firstName, *lastName, *company, *fullName = ""; // Variable inits.
static double salary = 0;
};
void main()
{
NameStorage *names[] = new NameStorage[3];
for(int i = 0; i < 3; i++) //Meat of the program, asks for input and assigns it to the objects.
{ // Error is coming in that the individual elements of the array are not
// being updated independently.
Console::Write("First Name: ");
names[i].SetFirstName(Console::ReadLine());
Console::Write("Last Name: ");
names[i].SetLastName(Console::ReadLine());
Console::Write("Salary: ");
names[i].SetSalary(Convert::ToDouble(Console::ReadLine()));
Console::WriteLine(names[0].GetName()); //Displays the contents of each array element for troubleshooting.
Console::WriteLine(Convert::ToDouble(names[0].GetSalary()));
Console::WriteLine(names[1].GetName());
Console::WriteLine(Convert::ToDouble(names[1].GetSalary()));
Console::WriteLine(names[2].GetName());
Console::WriteLine(Convert::ToDouble(names[2].GetSalary()));
}
return;
}
Now I'm getting the following errors:
StringSorter.cpp
StringSorter.cpp(62) : error C2691: 'NameStorage' : invalid type for __gc array element
StringSorter.cpp(62) : error C3149: 'NameStorage' : illegal use of managed type 'NameStorage'; did you forget a '*'?
StringSorter.cpp(62) : error C2691: 'NameStorage __gc *' : invalid type for __gc array element
StringSorter.cpp(68) : error C2228: left of '.SetFirstName' must have class/struct/union type
type is 'NameStorage __gc *'
did you intend to use '->' instead?
Last Error repeats for each reference back to the class.
|
|
|
|
|
is there a way to create them programmatically?
|
|
|
|
|
My guess is that you are wanting to create an alogrithm that creates a wav file. This will be MUCH harder than making a standard recording due to the number patterns you will need to make in order to get the sound you want. In fact this would be a guessing game that may never produce the intended results. But to answer your question you will first need to create a program that creates the correct file structure. Here is a link to a place that describes this:
http://www.daubnet.com/formats/RIFF.html
Wav files are just a form of riff files (which were originally called iff files and were made by electronics arts for video games). For the ID section you will want to put "wav " and the data will consist of pairs of signed bytes. The byte pairs correspond to the push and pull that the speaker magnet will produce when the file is played.
Good luck
|
|
|
|
|
What is the best way to get the size of a block of code? I thought maybe I could treat labels as pointers sticking one at the beggining and on at the end, but my compiler won't let me do it that way. Any other ideas? I think it might take some ASM code to accomplish, but I barely know any. So if anyone happens to know the best approach...
|
|
|
|
|
size in what units? LOC? bytes?
if it's LOC you could try something like this neatened up with a few macros:
long foo()
{
long start = __LINE__;
long end = __LINE__;
return end-start;
}
If it's about generated code try generating assembly / machine code listings from your source when you compile for the appropriate files and then counting opcodes and operands
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Sorry for not being specific but I meant bytes. Well actually I thought of one way that might work. I could stick the code in a function with a void parameter and return, then I could measure the length from the start to the return. If anyone has a better idea, keep in mind the method used has to work at runtime. I can't believe that no one has developed a standard method of doing this in C since it has to come up at least fairly often.
|
|
|
|
|
Xzyx987X wrote:
I can't believe that no one has developed a standard method of doing this in C since it has to come up at least fairly often.
Erh, why?, what's the use of it?
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
I also want to know ?
maybe he's confuse and want to use sizeof ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I think he actually wants to get the op code size of eg.
<code>
void foo()
{
char buffer[] = "A";
printf("%s\r\n", buffer);
}
</code>
Which translates to something like:
<code>
<br><br>
section .data
<span style="color: green">; data aligned on a 4 byte boundary.</span>
buffer db 'A', 0, 0, 0
mxyzptlk db "%s\r\n", 0, 0, 0, 0
section .text
_foo:
<span style="color: green">; Storing general registers for good measure.</span>
pushaw
<span style="color: green">; pushing arguments from right to left.</span>
push dword buffer
push dword mxyzptlk
<br>
<span style="color: green">; calling the extern function.</span>
call _printf
<br>
<span style="color: green">; Cleaning up the stack</span>
add esp, 8
<br>
</code>
which again translates to some mumbo jumbo machinecode
But besides the point that it's very hard to see the value in that information, there is the problem of buffer, and the anonymous string "%s\r\n", being declared in a data segment, and the rest of the code goes in a code segment (well, generally anyway, but the rare exceptions really shouldn't count).
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
The issue here is self modifying code. In order to pull this off correctly I need to be able to tell the size of a code block so I don't read over it's memory bounds when copying it to another location. Yes I could just figure out the size and declare it as a constant or something, but this would have nasty results if I changed the code that was being copied and forgot to update it's size.
|
|
|
|
|
Can anyone help me with this one:
I am tying to write an application that uses separate thread to communicate with the COM port. Everything is working fine but when I try to cancel the communication by using Thread::Abort() my application just freezes. What am I doing wrong?
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
You should find a manner to cancel any pending IO on the port first, and then signal to your thread to exit. The thread will 'naturally' exit if it leaves the bottom of the function.
Just blowing off the thread will result in several problems - you migth be failing to close the port, you might be leaking memory, etc.
|
|
|
|
|
I have been trying to create a splitter pane inside a tab control but have been unsuccesful so far. Can anybody point me to simple example of splitters inside a tab control. I have seen one on code project, but its just too complicated.
a
|
|
|
|
|
|
|
Yes I've looked at that..its just too complicated for a begineer like me to understand as yet. Anything else that you might know of?
A
|
|
|
|
|
I would like to automatically launch a dialog box at start up! Where should I place the code, in the Doc or View class and which methods would be best.
Any help would be appreciated. Thanks
|
|
|
|
|
The modeless dialog needs to be a member variable, of your main window class I'd say.
Create it when the main window is created.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I have a .NET C++ compiled MDI application that is displaying discrepancy between the release and debug configurations. The application basically draws/paints a map in the client areas. I am noticing that in the debug version, the map draws fine. However, when it is run in the release mode, the map doesn't get drawn. I have added the debugging hooks in the release configuration and recompiled and notice that the map draws (behaving like the debug version - which is kind of expected). So, I am not sure where to turn - Anyone have any ideas?
Thanks-
|
|
|
|
|
hi all my dear
i want to recover Win XP dialup pass
but i cant recover it bcu its non asterisk password
plz help me to recover it
but i need a source code or a metode to recover it
plz help me
thanks & thanks
|
|
|
|
|
plz heeeeeeeeeeelp
plz
sooooon its my university project
|
|
|
|
|
Buddy
that's hacking ,if you can provide me your ubniversity project guidelines ,then i can help otherwise you have to do it by own
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
What function should I use to check if a file exists? I came across it when I didn't need it, now that I need it I can't find it. Gotta love how that works.
Thanks!
Hua-Ying
|
|
|
|
|
PathFileExists() in shlwapi.h
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
Thanks, love your signature!
Hua-Ying
|
|
|
|