₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,273 members, 8,421,101 topics. Date: Friday, 05 June 2026 at 06:59 PM

Toggle theme

IbrahimB's Posts

Nairaland ForumIbrahimB's ProfileIbrahimB's Posts

1 2 3 4 5 6 7 8 9 10 (of 16 pages)

ProgrammingRe: @ C++ Gurus by IbrahimB: 3:44pm On Oct 02, 2010
Nice one!

As regards your question:
why does <= generate an error?
Remember that arrays (and vectors) in C++ are zero-indexed. So for an array of size = 10, the only valid indices are array[0] to array[9]. So your index always has to be < the size; obviously <= will generate an error.

Secondly, you have to be careful when dealing with pointers, as they can become invalid at anytime! A useful addition to your code would be:

if(Objects[i] != NULL)
{
   std::cout << Objects[i]->giveAttributes() <<"\n";
}
Or better still, you could decide to store copies of the objects themselves rather than their addresses. This makes sense since the objects are not so "heavy". You would then need copy constructors and assignment operators for that.

Lastly, you can consider returning and passing your strings by reference rather than by value. It is faster as no copying is involved.

std::string giveAttributes()
now becomes std::string& giveAttributes().

Cheers.
RomanceRe: Nyphomaniac Weds Dipsomaniac by IbrahimB: 1:27am On Oct 02, 2010
I hope they don't give birth to a Kleptomaniac.   shocked
FoodRe: Your Version/Idea Of A Nigerian Breakfast by IbrahimB: 5:24pm On Oct 01, 2010
symbianDON:
tuwo shinkafa with very thick beans soup laced with catfish. kai! i don de hungry again. a bowl of fura with sweetened yoghurt as dessert. chai!
Bros, na breakfast dem talk o  cheesy

Ranoscky:
Agbalumo & coke !!!
Sounds more like Rat Poison than a Nigerian Breakfast grin
ProgrammingRe: @ C++ Gurus by IbrahimB: 3:23pm On Sep 29, 2010
@Gameaddict

gameaddict:
Then I create a class called Box with  class Stuff as a child class.
It is very important to make proper use of terminologies. When you say child class, you are referring to inheritance. A child class inherits from another class (i.e. the parent class). That was why I brought the whole issue of Stuff being a kind of Box or not. The proper term to use in your case is member class.

Secondly, the issue of overloaded functions. If you're creating only one single function for registering stuffs, then overloaded function wouldn't be the right term to use.
ProgrammingRe: Please I Need Ur Help Please by IbrahimB: 12:12am On Sep 29, 2010
C# is very good to start with. You can use it for web, desktop and mobile development. It is becoming increasingly popular and there's lot of demand for C# programmers. smiley
ProgrammingRe: @ C++ Gurus by IbrahimB: 12:05am On Sep 29, 2010
gameaddict:
Maybe this will work.
You'll have to try out to know. wink

What do you really need an overloaded function for?

Is inheritance the best relationship to use? It seems composition and not inheritance is what you really need. If "Stuff is a kind of Box" does not sound right, then it's better you do away with inheritance.

If Box is just to store stuffs, just create a vector of stuffs member, right within the Box class. Then create an "add" function for adding Stuff objects to the container.

Good luck.
ProgrammingRe: Please I Need Ur Help Please by IbrahimB: 10:56pm On Sep 28, 2010
enzo01:
Pls i need a vry gud site where i can dwnload a comprehensive ebook 4 c# or beta still, how can u guruz advise me on this? Tanks
Have you tried Google? Seriously.
There's a lot of information you can get from Google if you search with the right keywords. The express edition of C# is available from Microsoft for free.
ProgrammingRe: @ C++ Gurus by IbrahimB: 10:43pm On Sep 28, 2010
gameaddict:
The main problem is creating the member function in Box to find and access each instance of Stuff on it's own.
It shouldn't be a problem. In the example provided, 'stuffs' was declared static so that it is independent of any instance of the Stuff class. It was protected so that it's accessible to the Box class.

All you need to do is to create a member method for Stuff to update 'stuffs' anytime you create an instance of the Stuff class. 'stuffs' is automatically available to the Box class.
ProgrammingRe: @ C++ Gurus by IbrahimB: 2:44pm On Sep 28, 2010
I guess you can do so, although it's not really clear what you want to achieve?

class Stuff
{
protected:
   static vector<Stuff*> stuffs;
}

class Box: public Stuff
{
  //create method to access "stuffs"
}


Anytime you create a new instance of the Stuff class, just update "stuffs". Just note though, that if the instance of the Stuff class goes out of scope, then the stored pointer will be invalid!
SportsRe: I’ve Proved Locomotiv Fans Wrong – Osaze ! by IbrahimB: 8:40am On Sep 28, 2010
It's good he now has his hair the way it should be.
SportsRe: Snake Welcome Athlete In Delhi For The Commonwealth Games by IbrahimB: 9:28pm On Sep 27, 2010
What would the world have said if it happened in Africa? undecided
PoliticsRe: 2011: Atiku Challenges Presidential Aspirants To Debate ! by IbrahimB: 3:10pm On Sep 22, 2010
Debates don't win elections in Nigeria. Nigerians like you, or they don't like you, that's all.
SportsRe: Messi Vs Ronaldo(who Is Better?) by IbrahimB: 5:53pm On Sep 04, 2010
SportsRe: Now I Believe The British Media Are Biased Towards Nigeria by IbrahimB: 8:48pm On Aug 30, 2010
@OP

Topic should read: "Biased against Nigeria" and not "Biased towards Nigeria"  wink
PoliticsRe: Professor Traces Biblical Eden To Nigeria. by IbrahimB: 9:38am On Aug 29, 2010
Abagworo:
Cain was given a mark so that other people would not harm him.who were these people?
Igbos perhaps? undecided
SportsRe: Mr Cooreman Has Proved His Worth, New NFF Should Listen by IbrahimB: 12:24am On Aug 27, 2010
Well at least, if employed, we'll have a foreign coach that will not run away
FoodRe: How Do U Love Your Beans? by IbrahimB: 7:58pm On Aug 22, 2010
^^^
The amount of fusion and fission that will take place in that stomach enh. . . cheesy
You no go wan look beans for the next 1 week!
SportsRe: Mikel Obi Please Score A Goal Or Shoot On Target by IbrahimB: 8:19am On Aug 22, 2010
chidichris:
is it possible that the enemies have sourrendered?
If someone says you should improve, that doesn't make him your enemy.
FoodRe: How Do U Love Your Beans? by IbrahimB: 8:16am On Aug 22, 2010
^^^
Enjoyment ke? This one na Grenade!
RomanceRe: She Is Positive With Hiv Yet She Want Me To Sleep With Her. by IbrahimB: 10:21pm On Aug 20, 2010
pappy2000:
all i want is your advice on how to tell her no,without hurting her.
I think you should be more concerned about her hurting you  undecided
SportsRe: Siasia’s Plans For Local Players : by IbrahimB: 1:37pm On Aug 19, 2010
^^^
All coaches "know" what they are saying until they start the job.
CultureRe: Kneel Down And Feed Your Husband? by IbrahimB: 8:42pm On Aug 18, 2010
How this is an issue, I just can't understand.  huh
SportsRe: Siasia Seals Deal Tuesday !! by IbrahimB: 5:33pm On Aug 17, 2010
Well, today is Tuesday undecided
ProgrammingRe: Java by IbrahimB: 2:47pm On Aug 17, 2010
You did not post the compiler errors? I am not sure there is a var keyword in Java - however, I may be wrong. Looks more like Javascript to me. Try this:

char[] specialXters = {'*', '|', '\', ':', '<', '>', '[', ']', '{', '}', '\', ';', '(', ')', '@', '&', '$', '#', '%'};
int numberOfXters = 19; //about 19 characters in this case

for(char c: strLine)
{
int i = 0;
while(i <   numberOfXters)
{
  if(c == specialXters[i++])
  {
   System.out.println("Characters found"wink;
   break;
  }
}
}


Insert this into your code. I don't do Java though, but I think should work. If you have any problems tell us the compiler error you're getting as well.
European Football (EPL, UEFA, La Liga)Re: Man Utd Vs Newcastle Utd On Monday 16th Aug. 2010 @ 7:00pm Live @ Old Trafford by IbrahimB: 11:59pm On Aug 16, 2010
Now that was a quick reply smiley

Maybe Messi is not the best player in the world, but I doubt if an average player can win FIFA player of the year, or score 47 goals in a season. The last person to do that was Ronaldo in the 90s.

You may not like Messi mama-gee, but his statistics are indeed impressive.
European Football (EPL, UEFA, La Liga)Re: Man Utd Vs Newcastle Utd On Monday 16th Aug. 2010 @ 7:00pm Live @ Old Trafford by IbrahimB: 11:50pm On Aug 16, 2010
mama-gee:
[color=deeppink]Wayne rooney is one of the most overated players in the world after Lionel Messi.

This match just proved it, he can't even strike a ball properly.

And to think this mediocre player is being compared to Cristiano ronaldo and messi is one heck of a joke.[/color]
You seem to have two contradictory opinions of Messi, mama-gee. If it is a joke to compare Rooney to Messi, then
how can Messi be said to be over-rated? It means Messi is doing something right. . .
ProgrammingRe: Java by IbrahimB: 7:14pm On Aug 16, 2010
Good. Now people can step in and help. Note: this is probably not valid Java code but your program should look something like this:

char[] specialXters = { '*', '%', '&', '/', '\' }; //I don't know if this is what you mean by special characters?

while ((strLine = br.readLine()) != null)   
{

      // Print the content on the console
      System.out.println (strLine);

     foreach(char c in strLine)
     {
           int i = 0;
           while(i < 5)
//because I have 5 special characters in this example
           {
               if(c == specialXters[i++])
               {
                 System.out.println("Special Character found!"wink;
                 break;
               }
           }
     }
}


Essentially, create an array or list to hold your special characters. For each line you read, iterate over the characters in the line to find if the character occurs in your "special character array", if that happens, alert the user that a special character has been found.
PoliticsRe: Obasanjo, Ibb Crash Atiku’s Ambition by IbrahimB: 8:46pm On Aug 15, 2010
Stranded!
PoliticsRe: Why Bankole Disembarked from BA Flight by IbrahimB: 12:57am On Aug 15, 2010
ABEG, let them check the hand luggage, jor! angry
ProgrammingRe: Java by IbrahimB: 7:53pm On Aug 14, 2010
The complete code?  undecided
SportsRe: Super Eagles Job: Siasia Wants N15m Monthly & Us$1m Etc by IbrahimB: 11:05pm On Aug 13, 2010
Are those his only conditions? I would have expected him to add:

5. No Interference
SportsRe: Siasia Wants N15m Per Month To Coach Eagles by IbrahimB: 5:37pm On Aug 13, 2010
If its 15 million he wants, let the NFF find another person who is ready to deliver and for much less. . .

1 2 3 4 5 6 7 8 9 10 (of 16 pages)