Quick Question : Classes and Objects

How do I put a line between two names. I wanna put a "|" between
the name of two players how do i do that. when i use cout the line
just appears at the very left which makes no sense. I want my output to look

Michael Jordan | David Beckham instead of
Michael Jordan David Beckham

Thanks. Code Below.

1
2
3
4
5
6

player.name("Michael Jordan");
player.name2("David Beckham");
player.oneline();

cout << name1 << " | " << name2;
that is not correct. name1 and name2 are not defined
Anyone...I am sleepy now. I just wanna know that.
Disch's example wasn't aimed directly to giving you the answer. What you have to do is look at your code, which looks correct for it's purpose of assigning the names (the white space may become an issue) and combine it with the example Disch has kindly provided.
Last edited on
Can you post your whole code? Just to see how your oneline function works, etc.
Unless that function prints what the OP wants, it is irrelevant. I'm not trying to be a dick about it, it's just that you don't want to start asking people to post a bunch of code that you don't need to look or else it just gets long, boring and sometimes messy.
Yeah, isn't the player.oneline(); the function that prints what the OP wants? Because, I think, in like 2 and 3, the information in the member variables, which represents the first and second name. In the 4th line, which is the function, I'm assuming it's to display the information in which he's trying to display?

And, in order to see why it doesn't print out that way, don't we need to take a look at the player.oneline(); function?

Is that wrong? Or does that make sense?

I'm new btw.
It really comes down to what the OP has to say. If the player.oneline () function is used to print it, then yes, we will need to see it. As I have already mentioned, the answer lies in front of everyone now, all the OP has to do is combine what he/ she already has with what Disch has provided.
I can't post the code..sorry but it prints in oneline . You I centered it by using for loop. I just need to know how to put "|" between names just so that they look like different names.
And my code works perfectly fine, there is no mistake.
If anyone can reply in the next ten mins, then it will be good. But do post how to do it.
I don't know what you expect.

You say your code has no mistakes, but clearly it does because it doesn't do what you want.

You say you want us to fix your code, but you don't show us any code. How can we fix what we can't see?

I just need to know how to put "|" between names just so that they look like different names.


I already showed you. You just output " | " between the names like I did in my previous post. That's all. Maybe I didn't get the names of your variables exactly right, but how could I? You never told me what your variable names were.
Topic archived. No new replies allowed.