Narue 5,707 Bad Cop Team Colleague

>This one is simple just copy the function prototypes in a file say header.h
Not quite. The question refers to function definitions. A prototype is only a declaration, not a definition.

Narue 5,707 Bad Cop Team Colleague

>If you are a likeable person, who did not lie on their resume, then you will get the job
What a naive statement. :icon_rolleyes: Sure, when I'm interviewing candidates, I take their personality and how well they would mesh with the rest of my team into consideration. If we get along it helps, but that doesn't get them the job unless they also demonstrate the knowledge and ability that's required for it.

Narue 5,707 Bad Cop Team Colleague

Employers typically assume practical experience, such as the time you've worked professionally or on significant projects (ie. open source). If you add a year for the time you spent in your room writing variations of "hello world", that would be padding your resume.

Narue 5,707 Bad Cop Team Colleague

>I am not looking for quick answers.
So slow ones will do? ;)

>If I have passed data between forms before I would be happy to know what
>question that was because I have left out this question for 2 months.
I remember reading a thread where a public property in one form allowed another form to get private data. You're one of the few people who asks about C++/CLI on this forum, and I'm pretty sure it was you, though I could be wrong.

>This is the only way I communicate between the Forms,
>passing strings and text right now through textfiles.
Read up on properties. I can only mention it so many times before I get tired of my advice being ignored.

Narue 5,707 Bad Cop Team Colleague

>If I type some integer in it, it is ok.
The error is correct, but not as informative as it could be. Just because you declare a variable to be const doesn't mean that it's guaranteed to be a compile-time constant. In this case, aFormatCtx->bit_rate probably can't be resolved at compile time, so you can't use the resulting const value as the size of an array.

If any part of the size is calculated at runtime, you have to simulate arrays using pointers and dynamic memory (not recommended), or you have to use a container class that manages the memory for you, such as std::vector.

Narue 5,707 Bad Cop Team Colleague

>I am not sure if you could meen that I can get the String from Form2
What I mean is that you need to engage your brain around here, because you've been told how to pass data between two forms before: use properties or events. Generally, if you ask the same question multiple times, we assume you're nothing but a mindless leech looking for quick answers, and nobody will want to help you.

>I have declared the richTextBox as public on Form2
That's about the worst possible solution. If you have to make private data public, you're doing something wrong.

Narue 5,707 Bad Cop Team Colleague

I do recall reading one of your threads that asked basically the same question and received a good answer (an answer which would solve your current similar problem). Perhaps you should take the time to learn the concepts of the answers you're given rather than just slapping the example code into your project and hacking it into submission.

Narue 5,707 Bad Cop Team Colleague

>lol, works fine...
Yes, but I imagine the OP wants the precision to be printed as well. Input of 1 and 5 should print 15.000000 rather than 15, for example. To do that has nothing to do with the type and everything to do with how it's printed:

cout<<"The sum of the range is: "<< fixed << addRange(x, y) <<endl;
Narue 5,707 Bad Cop Team Colleague

>Any help is good =]
I'm curious, can you define what you mean by "help"? Because it looks a lot like you want us to do your homework for you.

Anyway, this may help you.

Narue 5,707 Bad Cop Team Colleague

>I have been trying to learn C++ for a few months know but I'm still not 100%.
I've been trying to learn C++ for well over a decade. My job requires intimate knowledge of the language, but I'm still not 100%. Don't get frustrated if you find yourself confused, because confusion is pretty much a constant state for programmers.

>Should I go straight onto GUI or stay on basic C++ and learn that until 100%.
You should be comfortable enough with the core language that it won't get in the way when you start to wrestle with the concepts of GUIs. For example, if you're struggling with how functions or classes work then you're extremely likely to get overwhelmed when events and callbacks enter the picture.

Narue 5,707 Bad Cop Team Colleague

>no matter what I try the output remains integer
If you perform an operation on two integers that wouldn't have any precision even if converted to a double, why would you expect anything but a zero precision? No amount of casting will create something that isn't there.

Narue 5,707 Bad Cop Team Colleague

>char in C/C++ actually is a 8-bits integer ranging from 0 to 255.
While that may be true on your PC, C and C++ don't require char to be an 8-bit type. Further, vanilla char is allowed to be either signed or unsigned (the choice is made by your compiler), in which case even an 8-bit char may not have the range you specified.

invisal commented: thanks +4
Narue 5,707 Bad Cop Team Colleague

>Are basic types automatically initialized to 0 in C++ when allocated via new ?
No, automatic default initialization of built-in objects doesn't happen most of the time. You'll see it with objects that have static storage duration, typically. But you can force default initialization with an explicit empty parameter list:

int *nums = new int[10]();
Narue 5,707 Bad Cop Team Colleague

I think you're confused. Just use vectors where you need more than one instance of any kind of data. When you create a character, also add that character to the list of "other characters". It doesn't seem like a terribly difficult thing to me, but then again, you're still not being very clear.

Narue 5,707 Bad Cop Team Colleague

>i would this in DOS using TSR program to fire events with....
I would too...15 years ago, and only on DOS because TSRs were a hack to get around the weaknesses of an OS that couldn't handle more than one running program at a time. Now I'd use the event management or polling mechanisms of whatever multitasking OS the program is written for.

>Is it then possible to update the sleep time accordingly?
Yes, but then you're entering the realm of multiple threads/processes. One thread polls for changes to the requirements and another performs work based on the currently saved requirements.

Narue 5,707 Bad Cop Team Colleague

>I'm unable to make these programs and have to submit on thursday!!
Whining about it doesn't accomplish anything. The questions aren't difficult if you were paying attention in class, so you've only yourself to blame. Take the failing grade and learn your lesson, is my advice.

>Q. Make a header file that contains the function definitions of all the function prototypes
I don't like the wording of this question. Function definitions shouldn't be in a header because unless you're very careful you'll get errors, and even when you're very careful, the result is confusing.

>Q.Using unions, write a program [...]
One could argue that unions are an unnecessary part of the language for the majority of programmers.

>Q. Write a recursive procedure that returns the smallest value in an array of 10 elements.
I don't like this question either. It suggests that recursion is a good solution for linear algorithms where a simple loop is both shorter and simpler.

Narue 5,707 Bad Cop Team Colleague

Well, you can get it to count up, so now you need to get it to count up and then back down again on the same line. How about stopping at half of what you were stopping at, then printing j until it reaches 0?

for ( i = 1; i <= N; i++ ) {  
  for ( j = 1; j <= N - i; j++ )
    cout<<" ";

  for ( j = 1; j < i; j++ )
    cout<< j;

  do
    cout<< j;
  while ( j-- > 1 );

  cout<<'\n';
}
Narue 5,707 Bad Cop Team Colleague

>if you no what I mean
No, I don't. It seems like you don't feel your question has been answered adequately. If that's the case, post your code so we can see what you're doing now and can get a better idea of what you might be asking for.

Narue 5,707 Bad Cop Team Colleague

>so i can't fix this?
It's hard to fix something that isn't broken. If you don't like the current result, change your formatting to better suit the display medium, or change the display medium to something better suited for your formatting.

Narue 5,707 Bad Cop Team Colleague

>it does not work and it makes the header go down to a second line
Unless you're actually printing a newline character somewhere, the problem is your console window isn't wide enough and wraps around. Try redirecting your output to a file and I'd be willing to bet that it looks just fine.

>Is there a way to expand the actual command prompt?
Not that I know of, at least not without delving into the realm of creating your own windows.

Narue 5,707 Bad Cop Team Colleague

Well, you also need to add the objects to the vector using something like characters.push_back ( my_character ); .

Narue 5,707 Bad Cop Team Colleague

>I just can't get them all in one line using setw()
Show us your code that uses setw, an example of the output you're expecting, and an example of the output you actually get.

Narue 5,707 Bad Cop Team Colleague

>While compiling in turbo c++ change
> #include<iostream> to #include<iostream.h> >same goes for "string" I believe you know this already
First, when compiling in Turbo C++...don't[1]. Second, changing <string> to <string.h> won't fix anything because those two headers are completely different. <string.h> holds the C string library functions and types while <string> hold the C++ string class. The two headers are not interchangeable.

[1] Unless it's Turbo C++ Explorer, which is a modern compiler in the same product line.

Narue 5,707 Bad Cop Team Colleague

>this code isnt workin
This is a waste of keystrokes. Do you go to the doctor, say "I don't feel good", and expect an accurate diagnosis? Do you go to the mechanic, say "My car is broken", and expect the actual problem to get fixed? If you answered no to either of those, why would you say to us "This code isn't working", and expect any response other than "Be more specific!". Seriously, it doesn't take much brain power to figure out that we need more information to help you, and if you can't understand that much, you have no business writing code.

>m not able to solve the errors showing
The code compiles and runs fine for me on Visual Studio. Maybe if you told us what errors you're getting... :icon_rolleyes:

Narue 5,707 Bad Cop Team Colleague

>I thought I asked a question about friends and how
>inheritance works with classes that have friends
Yes, that was indeed your question.

>not whether cats and dogs can be friends, or what
>access a remote control should have to a TV
There's no need to get defensive. Besides, my answer is independent of your design. A good bridge between two classes can take the place of friends, increase flexibility, and reduce coupling.

>Btw, the latter is the example used by the 'C++ Primer Plus"
>book by Stephen Prata when explaining friends.
Beginner books often choose examples that are more accessible to the target readership and are designed to teach a programming concept rather than a good design concept. They're typically nonsensical (the remote control example), broken (the shape example), or woefully incomplete (any animal example).

Narue 5,707 Bad Cop Team Colleague

>doesn't matter -- sizeof(char) is still 1.
Yes, but sizeof(wchar_t) may not be. Worse, you won't get any kind of warning or error if you change char to wchar_t and forget to add the size multiplier, and you'll likely be invoking undefined behavior all over the place by allocating only a fraction of the memory you think you're allocating.

This is a very dangerous bug, and because of that it's a better practice to include the multiplier, even if you know that sizeof(char) is guaranteed to be 1.

Narue 5,707 Bad Cop Team Colleague

>Which of those are ok and which are not (if any)?
They're all valid XML. The extra space in an empty element is a style guideline in XHTML for compatibility reasons, but that has to do with conforming applications and not the requirements of a parser.

>can there be whitespace between the attribute name and
>the equal sign and the equal sign and the attribute value
I think this will be the least of your problems, but yes, whitespace between markup elements is allowed. The big issue is figuring out where whitespace is significant, and the XML specification will tell you that in painful detail. ;)

Narue 5,707 Bad Cop Team Colleague

>2) remove sizeof(char) because its value is guarenteed by the C languauge to always be 1.
But what happens when you decide to support wide characters and forget to add it back?

Narue 5,707 Bad Cop Team Colleague

>what i know that cin.rdbuf returns all what in the buffer
Kind of. It returns a pointer to the buffer object.

>but why loop happens
It's library magic. The << operator reads everything it can from the object it's given, and the buffer object will return characters from the attached stream until end-of-file. Together this "creates a loop", if that's how you want to describe it.

Narue 5,707 Bad Cop Team Colleague

Good advice in general. The particularly noticeable poor advice is smoothed out by clearly being specific to Google and practicality with their existing code base. While I can see their reasoning, I very much dislike their stance on exceptions. Hopefully non-Google people reading this guide will ignore that convention.

iamthwee commented: I really don't like ya avatar, it doesn't convey a professionalism. I think you should change it. -3
Ancient Dragon commented: jamthwee is just jealous :) +31
Narue 5,707 Bad Cop Team Colleague

Why not?

Narue 5,707 Bad Cop Team Colleague

>my question is why can't we initialize np->name=name directly ?
Well, you can if you want to, but it likely won't do what you want. Copying pointers around just means you have a bunch of aliases to the same block of memory. When people do an assignment like np->name = name; they typically want a copy of the data itself, not just a copy of the pointer.

Narue 5,707 Bad Cop Team Colleague
if (cin.good())
{
  break;
  cin.sync();
}

The sync call will never be reached in this snippet because break leaves the loop immediately.

>why ??
Because when you type a value that cin doesn't expect (ie. a non-integer character when an integer is expected), cin goes into an error state. When cin is in an error state, all input requests do nothing until you clear the state.

What your first example does (in theory) is clear the state and then discard all of the characters in the stream so that you wipe the slate clean and can try again. The second example tries to discard all of the characters in the stream first, even though the stream is still in an error state and the sync call is effectively a no-op because of it.

I say "in theory" because cin.sync() isn't required to flush the input stream.

Salem commented: Doin' the safety dance! +18
Narue 5,707 Bad Cop Team Colleague

>Based on Narure's response I gather that I need to make the subclasses of TV and the
>corresponding subclasses of RemoteControl friends of each other - and simply make sure that
>a subclass has access to any parent function the friend class might need (define them
>protected in the parent class).
Why don't you just make sure that the public interfaces are sufficient for communication between the TV and remote classes? You probably don't even need friends.

Narue 5,707 Bad Cop Team Colleague

Using read and write to serialize your objects is generally a bad idea. At the risk of being too vague, I'll distill all of my experience into one piece of advice for your convenience:

When you want to serialize an object manually, convert each of the fields to a string, format them as desired, and then write the string to a file. When you want to deserialize an object manually, read the string from your file, parse the string in a constructor, and populate the data members.

In code form, such a solution would look like this:

#include <sstream>
#include <string>
#include <vector>

class student {
public:
  std::string name;
  std::vector<std::string> classes;
  std::vector<int> grades;
public:
  student() {}
  student ( const std::string& serialized )
  {
    std::stringstream src ( serialized );
    std::string class_name;
    int grade;

    // No error checking
    std::getline ( src, name, '|' );

    while ( std::getline ( src, class_name, '|' ) ) {
      classes.push_back( class_name );
      src>> grade;
      grades.push_back ( grade );
    }
  }
public:
  std::string serialize ( std::ostream& out )
  {
    // Assume grades and classes are parallel
    // No error checking
    std::stringstream serialized;

    serialized<< name <<'|';

    std::vector<std::string>::size_type i;

    for ( i = 0; i < classes.size(); i++ ) {
      if ( i != 0 )
        serialized<<'|';

      serialized<< classes[i] <<'|'<< grades[i];
    }

    out<< serialized.str();

    return serialized.str();
  }
};

This way you don't have to know the POD type rules, you don't have to worry about what's undefined behavior and what isn't, and you retain maximum portability.

Narue 5,707 Bad Cop Team Colleague

>i just can't imagine it being really THAT hard of a feature to implement.
It's not. In fact, I believe it's a feature of vBulletin if you choose to enable it.

>i really wish threads that have been inactive for
>more than 90 days would be automatically locked.
I don't. It's a good idea in theory, but painfully annoying in practice. Besides, there's no rule against adding to an existing discussion, regardless of how old it is.

Narue 5,707 Bad Cop Team Colleague

>'foo' by itself is the address of the fn.
You can do two things with a function: call it and take its address. Both foo and &foo do exactly the same thing, but I prefer the latter because it's more obvious that I'm looking for an address.

You can also omit the pointer junk from the actual call:

printf ( "%d\n", p() );

But I generally keep it for the same reason, it's more obvious what's going on.

Narue 5,707 Bad Cop Team Colleague

>i want to hide those lines and it will be replaced with another statement.
Technically those lines don't belong to you and you shouldn't be messing with them. This is akin to the "how do I clear the screen" question, where the answer is "you don't, it's anti-social". But if you want to get rid of them, the easiest way is to clear the screen.

>how to make the screen window fixed (meaning not resizable anymore)?
Your ability to control the console window is pretty limited. If you want more control, switch to a graphical interface using Win32 or MFC. But keep in mind that as soon as you get into windows and graphics, C++ gets much more complicated.

Narue 5,707 Bad Cop Team Colleague

Don't forget the argument list when you call the function through a function pointer:

#include <stdio.h>

int foo ( void )
{
  return 12345;
}

int main ( void )
{
  int (*p)( void ) = &foo;

  printf ( "%d\n", (*p)() );

  return 0;
}
Narue 5,707 Bad Cop Team Colleague

>Why doesn't this work?
It works as intended, what did you expect it to do?

Narue 5,707 Bad Cop Team Colleague

Just remember two basic rules and you'll be fine:

1) Being my friend doesn't make you a friend of my children.
2) Being my friend doesn't make you a friend of my other friends.

>What effect does making the friend class protected have
Zero. It doesn't matter if the friend declaration is private, protected, or public, the effect is the same across the board.

Narue 5,707 Bad Cop Team Colleague

>Does anyone want to help?
No.

>A disassembler would be good, too.
www.google.com would be a good place to start searching.

Narue 5,707 Bad Cop Team Colleague

>Is C++ knowledge ok?
Yes.

Narue 5,707 Bad Cop Team Colleague

I'd recommend that you use the std::set class. It has O(log N) time complexity for search-based operations and the duplicate rules mean that you don't need any special logic for finding unique grams.

Narue 5,707 Bad Cop Team Colleague

This should be your first Windows programming book.

Narue 5,707 Bad Cop Team Colleague

>temp1=temp;
>temp1->next=start2;
You say start2 is a null pointer, right? Well when you assign temp to temp1, you're aliasing temp, not copying the data at that address. So when you set temp1->next to null, temp->next is also set to null implicitly.

You probably want something more like this:

temp1->data=temp->data;
temp1->next=start2;
Narue 5,707 Bad Cop Team Colleague

>I am simply adding in that Delphi and VB are capable of doing games
Any language can be used to make games. Any language that has access to a graphics API can write graphical games. This doesn't make all of those languages well suited to making games.

>but was not sure if the reasoning for not mentioning them was due to
>lack of help (in this particular forum), or if c/c++ were the better choice.
It's the latter. Invariably, the people asking about writing games aren't thinking about Flash games or simple Java applets. They're thinking about World of Warcraft, Halo, or something along those lines. And for those type of games C, C++, and assembly are the kings both in common use and prerequisite knowledge.

Narue 5,707 Bad Cop Team Colleague

>not sure what you mean by "in a position to objectively
>compare the languages for your needs"
Basically, if you don't know both languages well enough to choose the right one for what you're doing.

>mainly asking since both delphi and c are products of borland.
Delphi is specifically a Borland product. C is an internationally standardized language with many implementations, one of them being a Borland product. If you don't like Borland's IDE for C, you can choose among the others. A bunch of them are free.

>I would be happy to take up c as well but if the
>2 are capable of doing basically the same thing.
Put simply, C can do everything Delphi can and a great deal more because it's not restricted to a single platform (unless you count Kylix, which I would not).

>Don't understand why there isn't much help in the
>way of game code for Delphi as there is for c.
I don't understand how you missed the masses of links to help on google.

>But I do understand your point " it is the older generation, and some people don't
>like to change esp when the current language (c/c++) has been proven successful.
It's nice you understand, but that wasn't my point at all.

Narue 5,707 Bad Cop Team Colleague

>Is there any specific reasoning one would not recomend vb or
>more specific to my needs Delphi using DelphiX to design games?
Most of the questions are far too general to recommend anything but the most common and widely used languages. Due to their saturation of the field and the fact that many modern languages are based off of them, C and C++ are pretty much required if you want to be a professional game programmer and still remain competitive. Whether you actually use them depends on the games you intend to write.

>Should I move out of Delphi and start learning another language
I always recommend a firm background in C, period. I also recommend at least rudimentary assembly experience. Beyond that, learn what interests you and what you think you'll end up using.

>Would I be better switching languages?
If you aren't in a position to objectively compare the languages for your needs, you would be better off not switching.

Narue 5,707 Bad Cop Team Colleague

>It's hypnotizing effect causes painfull eyes and a significant decrease in concentration
If you find that hypnotic, don't watch the version with music. :D

John A commented: hahahahaha +15
WolfPack commented: I like the avatar. Don't care about what Joe says. +8