Anyone who thinks I'm clogging up the thread, please rate me dumb. If I really am too blind to see that, just give me a sign and I'll shut up.
I can't see why anyone would hold back posting his/her problems because two others are debating some point.
The thing with using big everything-gets-done-for-you-style libraries is that you get more experienced with their way of doing things, while you should be able to do stuff with your own hands.
2 years of learning C++ sound much, but if you think that your skills are lacking then I think you should try to stay small.
Making problems go away by just doing another exercise won't help you in learning how to make problems to really be gone.
I thought Ogre3D had a big community behind it. When I tapped into it the tutorials worked just fine for me. And it also has proper documentation (I just [url=http://www.ogre3d.org/docs/api/html/annotated.html]re-checked[/url] ).
Setting it up on Linux is - as with almost all somewhat popular libraries - piss easy. While the procedure often requires a little more work in Windows, it's still easy enough.
Of course encountering errors on something that should be trivial and out of the way fast is discouraging. But it feels so much better when you get it working and you know that's what you wanted to have in the first place.
I don't know much about Panda3D, but from the looks of it it holds your hand much more to guide you.
You should make up your mind if you just want to create something and be done with it, or if you want to learn something and deal with perhaps not finishing it.
[QUOTE=ZeekyHBomb;30803636]Anyone who thinks I'm clogging up the thread, please rate me dumb. If I really am too blind to see that, just give me a sign and I'll shut up.
I can't see why anyone would hold back posting his/her problems because two others are debating some point.
The thing with using big everything-gets-done-for-you-style libraries is that you get more experienced with their way of doing things, while you should be able to do stuff with your own hands.
2 years of learning C++ sound much, but if you think that your skills are lacking then I think you should try to stay small.
Making problems go away by just doing another exercise won't help you in learning how to make problems to really be gone.
I thought Ogre3D had a big community behind it. When I tapped into it the tutorials worked just fine for me. And it also has proper documentation (I just [url=http://www.ogre3d.org/docs/api/html/annotated.html]re-checked[/url] ).
Setting it up on Linux is - as with almost all somewhat popular libraries - piss easy. While the procedure often requires a little more work in Windows, it's still easy enough.
Of course encountering errors on something that should be trivial and out of the way fast is discouraging. But it feels so much better when you get it working and you know that's what you wanted to have in the first place.
I don't know much about Panda3D, but from the looks of it it holds your hand much more to guide you.
You should make up your mind if you just want to create something and be done with it, or if you want to learn something and deal with perhaps not finishing it.[/QUOTE]
Helping people isn't clogging up the thread, don't be hard on yourself :)
[editline]30th June 2011[/editline]
On a side note, I was wondering if there was such a thing in C++ as the the Python dictionary 'dict' [url=http://docs.python.org/py3k/library/stdtypes.html?highlight=dict#dict]source[/url]
Basically a variable that can store other variables of different types.
[QUOTE=Mr. Smartass;30794768]What is a good up to date book for xna game studio? The creators guide is sharply outdated.[/QUOTE]
Repost for end of page.
[QUOTE=T3hGamerDK;30803788]Helping people isn't clogging up the thread, don't be hard on yourself :)
[editline]30th June 2011[/editline]
On a side note, I was wondering if there was such a thing in C++ as the the Python dictionary 'dict' [url=http://docs.python.org/py3k/library/stdtypes.html?highlight=dict#dict]source[/url]
Basically a variable that can store other variables of different types.[/QUOTE]
I just skimmed through the documentation, but std::map should fit your needs.
Also, thanks. I just asked though because Samuka was saying that I am.
[QUOTE=ZeekyHBomb;30804082]I just skimmed through the documentation, but std::map should fit your needs.
Also, thanks. I just asked though because Samuka was saying that I am.[/QUOTE]
The problem with std map, though, is that it can only hold one data type,where as the python dict or array can hold any. Is it possible to do the same thing in C++/0x, or do I need to just use a LOT of maps for each datatype?
What you're trying sounds strange an an environment such as C++.
However, the Boost-guys provide a handy container for that, called boost::any. You could try to use that or deal with the black void-pointer magic to non-specific type yourself.
[QUOTE=ZeekyHBomb;30804794]What you're trying sounds strange an an environment such as C++.
However, the Boost-guys provide a handy container for that, called boost::any. You could try to use that or deal with the black void-pointer magic to non-specific type yourself.[/QUOTE]
I could try posting this in a python kind of way.
[code]
def authenticate(information):
// perform authentication
auth_info["usr"] = "mastersrp"
auth_info["pwd"] = insert_pwd()
auth_info["auth"] = True
auth_info["auth_lvl"] = 5
return auth_info
[/code]
This function (albeit being very dumb and quick) contains ints, strings and booleans and returns the object array containing different datatypes.
Would the boost::any be good for this? I'm already implementing the boost library, so it's not a problem, but I'd rather use C++/0x standards, if possible.
Struggling to understand c++.
I'm giving a function a char *, and an unsigned long *, it sets the result in the unsigned long *.
I do this twice, I need to then concat both of the unsigned long*s and append a third char *. Then md5 all of it.
Am bewildered. How should I go about concatenating these unsigned longs and a char?
[QUOTE=Jimbomcb;30808974]Am bewildered. How should I go about concatenating these unsigned longs and a char?[/QUOTE]
Concat them as a string or as a char[]?
Why aren't you using std::strings and std::stringstreams?
[QUOTE=esalaka;30809195]Why aren't you using std::strings and std::stringstreams?[/QUOTE]
Because I don't know any better... I'm just going off examples I'm finding around the internet.
The MD5 function needs it to be unsigned char, so I need to concat the unsigned longs into one unsigned char.
Chances are if you're using char * for strings you're doing something rong
[editline]30th June 2011[/editline]
'Cause you have to use cstring.h to manipulate them and you really could just use strings
I was just going off the other sourcemod extensions for that. for example they have
[code]static cell_t sm_Geoip_Country(IPluginContext *pCtx, const cell_t *params)
{
char *ip;
const char *ccode;
pCtx->LocalToString(params[1], &ip);
StripPort(ip);
ccode = GeoIP_country_name_by_addr(gi, ip);
pCtx->StringToLocal(params[2], params[3], (ccode) ? ccode : "");
return ccode ? 1 : 0;
}[/code]
Which puts params[1] to the char * ip. It's that char which I need to feed into
[code]static int interpret_key(const char *key, unsigned long *result)[/code]
And I need to get the result from two of them plus a third char *.
Oh
That's because GeoIP_country_name_by_addr is probably a C function and thus doesn't accept string references which would be a good way to accomplish this sorta thing in C++.
[QUOTE=ZeekyHBomb;30804082]I just skimmed through the documentation, but std::map should fit your needs.
Also, thanks. I just asked though because Samuka was saying that I am.[/QUOTE]
Oh nonono. I was implying that [b]I[/b] was clogging up the thread myself with my indecision, it probably came out wrong. Sorry. Anyways I am currently making a bunch of small projects on C++, I was just searching for something to actually make a complete project on. Once again, sorry for the bad wording.
[QUOTE=T3hGamerDK;30805724]I could try posting this in a python kind of way.
[code]
def authenticate(information):
// perform authentication
auth_info["usr"] = "mastersrp"
auth_info["pwd"] = insert_pwd()
auth_info["auth"] = True
auth_info["auth_lvl"] = 5
return auth_info
[/code]
This function (albeit being very dumb and quick) contains ints, strings and booleans and returns the object array containing different datatypes.
Would the boost::any be good for this? I'm already implementing the boost library, so it's not a problem, but I'd rather use C++/0x standards, if possible.[/QUOTE]
I don't think C++0x has anything like boost::any, unless void* (which qualifies as a pointer to anything), which can do the same thing, but you have to make sure you don't access anything invalid yourself (since with void* you have no idea what type the underlying data is (well, not directly; of course you can use an enumeration or something to store it separately)).
In that example you posted I'd use a struct/class.
If you really have heterogeneous data with unspecific types, you can, though a bit wasteful perhaps, represent them all as strings and store them in an array indexed by an enumeration such as
[cpp]enum auth_info {
user = 0,
password,
authenticated,
authentication_level
};[/cpp]
or as 'last resort' a std::map<std::string, std::string>.
This is better in regards of type-safety than void* or boost::any. Though I don't really know what to choose there.. I guess it depends on the specific circumstances of the data, the environment of the project, the mood I'm in and what I've eaten earlier.
[QUOTE=Samuka97;30810054]Oh nonono. I was implying that [b]I[/b] was clogging up the thread myself with my indecision, it probably came out wrong. Sorry. Anyways I am currently making a bunch of small projects on C++, I was just searching for something to actually make a complete project on. Once again, sorry for the bad wording.[/QUOTE]
Oh, as I just reread it with that knowledge I understand. I though it was a command, such as "Stop clogging up the thread!". My bad.
Also: Hearts, hearts everywhere.
[QUOTE=ZeekyHBomb;30810729]I don't think C++0x has anything like boost::any, unless void* (which qualifies as a pointer to anything), which can do the same thing, but you have to make sure you don't access anything invalid yourself (since with void* you have no idea what type the underlying data is (well, not directly; of course you can use an enumeration or something to store it separately)).
In that example you posted I'd use a struct/class.
If you really have heterogeneous data with unspecific types, you can, though a bit wasteful perhaps, represent them all as strings and store them in an array indexed by an enumeration such as
[cpp]enum auth_info {
user = 0,
password,
authenticated,
authentication_level
};[/cpp]
or as 'last resort' a std::map<std::string, std::string>.
This is better in regards of type-safety than void* or boost::any. Though I don't really know what to choose there.. I guess it depends on the specific circumstances of the data, the environment of the project, the mood I'm in and what I've eaten earlier.[/QUOTE]
Thanks [url=http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html]alot[/url]! I'll look up enum's then :buddy:
I'm new to learning C++, and I don't get how to implement classes and whatnot. I understand how classes work, and same with inheritance, but I just don't get how to implement it. Where to use :: and . and whatnot.
[editline]30th June 2011[/editline]
Also, I don't get something like
[code]Vector operator *(const float &scale, Vector &v)
{
Vector outV;
outV.setX(v.getX() * scale);
outV.setY(v.getY() * scale);
outV.setZ(v.getZ() * scale);
return outV;
}[/code]
I don't get it at all, I mean I could post the whole code and if someone would walk me through it or something I'd greatly appreciate that. I get the general idea of classes, that's simple, I just don't know what things like v.getX or whatever does! It's confusing to me.
What's a cross platform alternative to system("cls")?
[QUOTE=Biotic;30820745]What's a cross platform alternative to system("cls")?[/QUOTE]
There's none. However, you can make a function that changes compile-time to do each OSes clear.
Something like:
[cpp]clearScreen()
{
#ifdef WINDOWS
system("cls")
#elif UNIX
system("clear")
#endif
}[/cpp]
Of course, that would only work on Windows or Unix systems. However, if you really want to do this, you can use [url=https://secure.wikimedia.org/wikipedia/en/wiki/Curses_%28programming_library%29]curses[/url]. If you're using Windows, you'll have to use PDCurses. The unix implementation is called ncurses. Read the article if you're interested. It may be overkill, but it depends on what you're doing.
Very quick Q:
[quote]My computer usually runs several programs at the same time. For example I can have a
word processor, a web browser and a spreadsheet all running simultaneously. Sometimes
however, I run an old calculator program. It just waits for me to type in numbers to add,
subtract, multiply etc., and gives answers when I want them. When this program is
running everything else on my computer seems slow and unresponsive. What might be
happening?[/quote]
The only answer I can think of is simply because the CPU's multitasking, so while you're using your web browser the CPU is still waiting for calculator input... But is there anything else I could talk about as well? Perhaps why the calculator is slowing down the computer so much?
[QUOTE=Zally13;30817415]I'm new to learning C++, and I don't get how to implement classes and whatnot. I understand how classes work, and same with inheritance, but I just don't get how to implement it. Where to use :: and . and whatnot.
[editline]30th June 2011[/editline]
Also, I don't get something like
[code]Vector operator *(const float &scale, Vector &v)
{
Vector outV;
outV.setX(v.getX() * scale);
outV.setY(v.getY() * scale);
outV.setZ(v.getZ() * scale);
return outV;
}[/code]
I don't get it at all, I mean I could post the whole code and if someone would walk me through it or something I'd greatly appreciate that. I get the general idea of classes, that's simple, I just don't know what things like v.getX or whatever does! It's confusing to me.[/QUOTE]
You'll get used to it, it's just the syntax you appear to have problems with then, not the semantics. Go on in your book and read others code when you're finished :v:
[QUOTE=Chrispy_645;30821178]Very quick Q:
The only answer I can think of is simply because the CPU's multitasking, so while you're using your web browser the CPU is still waiting for calculator input... But is there anything else I could talk about as well? Perhaps why the calculator is slowing down the computer so much?[/QUOTE]
Nah, the scheduler should be able to handle this fine.
I'd rather think that he/she's using the RAM to the full extend and the OS is putting stuff to the swap/pagefile.
Perhaps it's already doing that on programs, which he/she just doesn't notice because they're in idle.
Watch the system monitor.
But could it also be related to the way the calculator was programmed? The question might've dropped a subtle hint in there... It says "old calculator program"?
I don't know why it should have such an effect.
Even if it was coded badly, it's just a calculator - though that could add to the theory that it hogs memory.
[QUOTE=Biotic;30820745]What's a cross platform alternative to system("cls")?[/QUOTE]
[cpp]
void clearScreen( int numLines )
{
for( int i=0;i>numLines;i++ )
{ std::cout << std::endl; }
}
[/cpp]
[QUOTE=T3hGamerDK;30822912][cpp]
void clearScreen( int numLines )
{
for( int i=0;i>numLines;i++ )
{ std::cout << std::endl; }
}
[/cpp][/QUOTE]
You could also do that as long as you know how many rows the terminal is and warn people not to scroll up.
[QUOTE=Jookia;30823211]You could also do that as long as you know how many rows the terminal is and warn people not to scroll up.[/QUOTE]
The function "clear" does this in most linux systems, afaik.
[editline]1st July 2011[/editline]
Without the warning though.
[QUOTE=T3hGamerDK;30823258]The function "clear" does this in most linux systems, afaik.
[editline]1st July 2011[/editline]
Without the warning though.[/QUOTE]
Yes, but the clear function knows how high my terminal is. The application does not.
[QUOTE=Jookia;30823388]Yes, but the clear function knows how high my terminal is. The application does not.[/QUOTE]
Then find a way to figure it out :]
Problem solving is one half of programming.
[QUOTE=Jookia;30823388]Yes, but the clear function knows how high my terminal is. The application does not.[/QUOTE]
It's also not a function, but a function starting a program.
I personally don't like doing it that way at all. Researching how to do it in the platform native API can get ugly though. Using something like curses creates dependencies you might not need otherwise.
It depends how much you want to do it the right way.
Yeah, as I said, the tradeoff in this case would be to use curses if you really want to be correct, or use a hacky system() call depending on what system you're on.
I know that clear is a program, but I really didn't want to get to be specific with stuff. If I did, I would've made the clearScreen() code snippet compilable.
Sorry, you need to Log In to post a reply to this thread.