|
I come from VB. Now I’m trying to learn C++ now. Can someone help me find good tutorials for someone without a Visual Compiler? Im using Dev-C++ 4.9.7.0
|
|
|
|
|
I suggest you read the title of this forum, then go to the right forum.
Hint: there are at least 2 forums on C++ depending on your exact needs.
|
|
|
|
|
Hello,
I would like to call a method multiple times by a count. For example:
If count = 6 call method 6 times.
Thank you so much for the help.
RB
|
|
|
|
|
for[^]
You need to read very basic c# book.
|
|
|
|
|
1.
for(int i=0; i< count; i++) myPopularMethod(withPossiblySomeArguments);
2.
or create a delegate and an event; add the delegate count times to the event and call the event.
|
|
|
|
|
He could also use the reverse-singleton pattern?
I are troll
|
|
|
|
|
|
Int control= count;
Whiskey:
if (control== 0)
goto Foxtrot;
else
goto Tango;
Tango:
MyMethodCall();
control--;
goto Whiskey;
FoxTrot:
Edit: Improved code.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
modified on Thursday, January 8, 2009 3:38 PM
|
|
|
|
|
I see everyone's using goto after yesterday's discussion!
int control = 5;
while (control > 0)
{
MyMethodCall();
control--;
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
That is such a bad use of goto...
for (int i=0; i<6; i++)
MyMethodCall();
|
|
|
|
|
Let's hope count is positive now.
|
|
|
|
|
Hi,
labels too deserve meaningful names, they add to the readability of the source code; so I would suggest:
uint control= count;
WhileThereMayBeMore:
if (control== 0)
goto FinallyWhenDone;
else
goto ThisIsWhereWeCallTheMethod;
ThisIsWhereWeCallTheMethod:
MyMethodCall();
control--;
goto WhileThereMayBeMore;
FinallyWhenDone:
BTW: why is it all examples seem to use PascalCase labels, they are local after all?
(e.g. read MSDN on the goto keyword)
|
|
|
|
|
My labels do have meaningful names when looked at collectively. Perhaps I was too subtle.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Sure they do, however you could combine individual and collective meaning, yielding the best of both worlds.
|
|
|
|
|
Hmm, I'm sure you could fit some XML in there, keep the counter in a database table, or even create a custom CountNotYetAchieved Exception class. I'd even settle for a string counter and Int32.Parse it on each iteration. Come on guys, integer counters are soooo yesterday! Here's my real version:
while(count-- > 0) MyMethod();
One other thing is the else technically is unnecessary in the Whiskey label...
Last, you could spice it up with if(!(control != 0)) , that would make it really nice!
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Hi, is it possible to make an application (it can be a web application or desktop, not much important) that to display a live video from a webcam? It will be both video and and sound.
I searched on it but, i couldnt find how to do it both video and sound together.
If u could help me, thanks for your answers from now.
|
|
|
|
|
|
I am looking at the system.windows.media.colors class and the system.windows.media.color struct
I assume there is some kind of collection in the colors class of the color struct, so when you type colors. it gives a drop down list of the color structs that are contained within the colors class.
I need to replicate the same kind of functionality, but am unsure on how to go about building the colors class to give the drop down showing named instances of the structs.
Any help most welcome
Mark
|
|
|
|
|
what about something like:
foreach(Color c in Colors)
{
ComboBox1.Items.Add(c.ToString());
}
|
|
|
|
|
I am trying to understand the underlying code of the colors class, so i can replcate it for a differnt use. It has the functionality i need, but i am going to use it for something other than colors
|
|
|
|
|
ahh then you may want to use an 'enum'
public enum Values{
One = 1
Two = 2
}
then acces like
Values.One
or Values.Two
modified on Thursday, January 8, 2009 12:28 PM
|
|
|
|
|
thats the kind of functionality i need, but it need to display structs, which is where i start getting stuck
|
|
|
|
|
You could examine the source of the Color struct.
A very simple implementation (loads missed out!) using the proper spelling...
public struct Colour
{
private byte m_R;
private byte m_G;
private byte m_B;
public Colour(byte r, byte g, byte b)
{
m_R = r;
m_G = g;
m_B = b;
}
public byte R { get { return m_R; } }
public byte G { get { return m_G; } }
public byte B { get { return m_B; } }
public static Colour White
{
get { return new Colour(255, 255, 255); }
}
public static Colour Black
{
get { return new Colour(0, 0, 0); }
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
EDIT - Scratch that, i have worked out how the above sorts everything out for me
THANKS
I agree about the spelling
|
|
|
|
|
yeah thats what i meant to write lol
|
|
|
|