• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 04:16
CET 10:16
KST 18:16
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns5[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1822Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises3Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies3
StarCraft 2
General
Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns SC2 All-Star Invitational: Jan 17-18 Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises Chinese SC2 server to reopen; live all-star event in Hangzhou Starcraft 2 Zerg Coach
Tourneys
SC2 AI Tournament 2026 WardiTV Winter Cup OSC Season 13 World Championship uThermal 2v2 Circuit WardiTV Mondays
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes Mutation # 504 Retribution
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ I would like to say something about StarCraft Data analysis on 70 million replays Empty tournaments section on Liquipedia A cwal.gg Extension - Easily keep track of anyone
Tourneys
[Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 SLON Grand Finals – Season 2
Strategy
Simple Questions, Simple Answers Game Theory for Starcraft Current Meta [G] How to get started on ladder as a new Z player
Other Games
General Games
Stormgate/Frost Giant Megathread General RTS Discussion Thread Nintendo Switch Thread Awesome Games Done Quick 2026! Should offensive tower rushing be viable in RTS games?
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Trading/Investing Thread The Big Programming Thread Canadian Politics Mega-thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
How do archons sleep?
8882
Psychological Factors That D…
TrAiDoS
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
GOAT of Goats list
BisuDagger
Customize Sidebar...

Website Feedback

Closed Threads



Active: 949 users

The Big Programming Thread - Page 294

Forum Index > General Forum
Post a Reply
Prev 1 292 293 294 295 296 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Orome
Profile Blog Joined June 2004
Switzerland11984 Posts
May 02 2013 16:29 GMT
#5861
Ah damn I found it. I used heap.reserve(capacity), but I believe that only reserves space for pointers? And I'm storing the actual elements in the heap? In any case, with a normal declaration of the size of the heap, everything works out.
On a purely personal note, I'd like to show Yellow the beauty of infinitely repeating Starcraft 2 bunkers. -Boxer
Zeke50100
Profile Blog Joined February 2010
United States2220 Posts
Last Edited: 2013-05-02 16:33:24
May 02 2013 16:31 GMT
#5862
On May 03 2013 01:17 Orome wrote:
Hey guys, was hoping someone could help me out again real quick. I'm trying to make a vector-based heap of std:: pairs. My solution seems to be identical to the one they provided us with, but somehow it doesn't work. When I try to do something like this:


heap[1] = item(k, e);


the program crashes.

item is defined as:

typedef std::pair<int, string> item;

heap's a class variable, defined as:

std::vector<item> heap;


I appreciate any help.


EDIT: Well, you found the error, so I'll spoiler the old answer.
+ Show Spoiler +
I suspect an out-of-bounds error: a std::vector does not have any "space" upon construction - its size dynamically grows as you need to add new stuff to it (or shrinks if you're taking things out of it).

heap[1] = item(k, e)

heap[1] is out-of-bounds because there isn't a [1] in heap.

std::pair<int, std::string> item(5, "apple pie");
std::vector<std::pair<int, std::string> > heap;
heap.push_back(item);


The "push_back()" function adds an object to the heap. After having added the item, you can now access it as "heap[indexNumber]" - in this case, "heap[0]" will let you access (5, "apple pie"). Alternatively:

std::vector<item> heap(10)


This will leave you with 10 default-constructed items (in this case, pairs of ints and strings).

std::cout << heap[0].second << '\n'; //will print "apple pie"
std::cout << heap[1].second << '\n'; //undefined behavior if the size of heap is less than 2
std::cout << heap.at(0).second << '\n'; //will also print "applie pie"
std::cout << heap.at(1).second << '\n'; //will throw an out-of-bounds exception, so you aren't confused


The at() function can help alleviate this problem.

A useful resource on vectors is here, in case you have other issues.
Sverigevader
Profile Joined March 2010
Sweden388 Posts
May 04 2013 15:37 GMT
#5863
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?
"I can answer this, you're just a god damn sexy mofo." http://www.teamliquid.net/forum/viewmessage.php?topic_id=147829&currentpage=7#139
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
May 04 2013 16:24 GMT
#5864
On May 05 2013 00:37 Sverigevader wrote:
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?


Nope.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
May 04 2013 17:44 GMT
#5865
On May 05 2013 01:24 netherh wrote:
Show nested quote +
On May 05 2013 00:37 Sverigevader wrote:
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?


Nope.

Negatory.
ddengster
Profile Blog Joined January 2009
Singapore129 Posts
May 04 2013 17:50 GMT
#5866
On May 05 2013 00:37 Sverigevader wrote:
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?


think you can do it with template specializations, but it's not worth the amount of code. Usually, you put the operator+ function within Fraction itself so it's treated as a method of the class, so there's no need to have a second global friend function for your 2nd line of code.

example:
class Fraction
{
public:
Fraction operator+(int i);

friend Fraction operator+ (int i, Fraction& f1);
};
Check out NEO Impossible Bosses, RTS-MOBA boss rush at http://neoimpossiblebosses.coder-ddeng.com
Kambing
Profile Joined May 2010
United States1176 Posts
May 04 2013 18:03 GMT
#5867
On May 05 2013 02:50 ddengster wrote:
Show nested quote +
On May 05 2013 00:37 Sverigevader wrote:
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?


think you can do it with template specializations, but it's not worth the amount of code. Usually, you put the operator+ function within Fraction itself so it's treated as a method of the class, so there's no need to have a second global friend function for your 2nd line of code.

example:
class Fraction
{
public:
Fraction operator+(int i);

friend Fraction operator+ (int i, Fraction& f1);
};


That doesn't solve the problem of requiring two separate functions.

In general, operator+ may not be commutative, so there is no automatic support for generating both forms of the operator. The simplest way is to implement one operator directly and (either as a free-floating function as you have or as a member function as ddengster described) and then implement the other operator in terms of the first.
WindWolf
Profile Blog Joined July 2012
Sweden11767 Posts
May 04 2013 18:35 GMT
#5868
I'm looking to learn C#, does anyone have any good tips on links where I can start reading/learning.
I know how to program in C++ and I'm a rusty on Java.
EZ4ENCE
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-05-05 03:49:32
May 05 2013 03:44 GMT
#5869
I'm having some trouble with a simple html page. I want to link some css. Can someone take a quick look?

Crosspost on stack:

http://stackoverflow.com/questions/16381132/how-do-i-get-text-in-my-html-page-to-display-features-using-the-css-stylesheet

Figured it out. Misconfigured stylesheet link.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
May 05 2013 18:46 GMT
#5870
What do you think of Extreme Programming methodology?

http://en.wikipedia.org/wiki/Extreme_programming
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
May 05 2013 19:41 GMT
#5871
On May 06 2013 03:46 darkness wrote:
What do you think of Extreme Programming methodology?

http://en.wikipedia.org/wiki/Extreme_programming


Depends on what part of it you mean.

Most programmers already do a lot of what extreme programming entails but going the full way has about as many problems as it has advantages, the same as most agile methodologies. The best is to do what works, to get ideas from other methodologies but to be critical and only apply the stuff that you really need and to be wary of overengineering the process instead of putting the effort into actual solutions.

There is no silver bullet.
Craton
Profile Blog Joined December 2009
United States17274 Posts
May 05 2013 20:01 GMT
#5872
Your organization has to try different methodologies and see which works the best for different types of projects (or just for your organization in general).

Mine does / has done a little bit of everything (waterfall, modified waterfall, scrum, other agile methods) and we've found pros and cons for everything (especially when working with the government).
twitch.tv/cratonz
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
May 05 2013 21:04 GMT
#5873
Alright, thanks for your thoughts. I'm not employed yet, but I have a module at university called 'Software Tools'. It defines itself as XP based, thus teaching us Ant, JUnit and Eclipse as well as the role of CASE (Computer-aided Software Engineering). I'm just curious if XP is practical in professional programming.
Craton
Profile Blog Joined December 2009
United States17274 Posts
Last Edited: 2013-05-05 21:14:53
May 05 2013 21:14 GMT
#5874
I don't find project management stuff to be very useful / important to know. Your organization should have a project / technical manager in charge of implementing and training everyone on what you're going to be doing.

If you want to be a PM/TM then that's another story, but as someone who develops and hates managerial stuff, I loathed that type of coursework.
twitch.tv/cratonz
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
May 06 2013 11:17 GMT
#5875
I have a class Creature with the protected int HP in C++. I have a subclass Enemy. Shouldn't enemy then get the int HP, as a sort of private int? I get the compiler error "class Enemy has no member named HP"

rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
May 06 2013 11:38 GMT
#5876
On May 06 2013 20:17 Arnstein wrote:
I have a class Creature with the protected int HP in C++. I have a subclass Enemy. Shouldn't enemy then get the int HP, as a sort of private int? I get the compiler error "class Enemy has no member named HP"



A bit harder to diagnose without knowledge of how they're implemented. Is everything defined properly?
There is no one like you in the universe.
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
May 06 2013 11:44 GMT
#5877
On May 06 2013 20:38 Blisse wrote:
Show nested quote +
On May 06 2013 20:17 Arnstein wrote:
I have a class Creature with the protected int HP in C++. I have a subclass Enemy. Shouldn't enemy then get the int HP, as a sort of private int? I get the compiler error "class Enemy has no member named HP"



A bit harder to diagnose without knowledge of how they're implemented. Is everything defined properly?


No, I fixed with the good ol' #ifndef and #define
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-05-06 22:39:15
May 06 2013 22:34 GMT
#5878
I am not sure how to call it exactly, but Objective-C can do something like this:

[[person child] setHeight:argument];

Is there something similar in Java/C++? Perhaps person.child.height = argument; but is inheritance involved here? I'm not sure if I understand code above. Perhaps you use a method from another class without calling an instance?
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2013-05-06 23:12:13
May 06 2013 23:08 GMT
#5879
On May 07 2013 07:34 darkness wrote:
I am not sure how to call it exactly, but Objective-C can do something like this:

[[person child] setHeight:argument];

Is there something similar in Java/C++? Perhaps person.child.height = argument; but is inheritance involved here? I'm not sure if I understand code above. Perhaps you use a method from another class without calling an instance?

As far as Objective-C is concerned, that block of code is calling the "setHeight" function with the "argument" as a parameter on an object returned from the "child" function of the "person" object.

I don't know the Java or C++ equivalent, but essentially it's a nested function call.
Craton
Profile Blog Joined December 2009
United States17274 Posts
May 07 2013 00:20 GMT
#5880
How does one go about writing a select statement (PL/SQL) that will accomplish the following:

Assume a "lookup" table with a pair of fields "match" and "replace" that have values like: À, A; È, E (such that you have pairs of "accented" characters in the match and "normal" characters in the replace).

Assume you have another table with n number of records, any of which have one or more characters matching this pattern. The end translation should go something like ÀNYWHÈRÈ -> ANYWHERE.

For a single value, I can use a CONNECT BY LEVEL to split each character into a separate field, join to the lookup table, and then use a MODEL construct to perform the replacement and concatenation of each character (ordering maintained), taking only the final "built" value. However, I can't make it work when I have multiple values (i.e. from a table), since I can't just connect it by level.

I feel there might also be a way to skip the CONNECT BY step altogether, but I can't make it happen.

Thoughts?
twitch.tv/cratonz
Prev 1 292 293 294 295 296 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 2h 44m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 145
StarCraft: Brood War
Rain 1584
GuemChi 1249
Larva 561
Pusan 356
Light 229
sorry 177
Jaedong 175
Leta 170
Hyuk 138
yabsab 74
[ Show more ]
Shuttle 72
Bale 43
ZergMaN 38
NotJumperer 37
Sacsri 24
zelot 20
Rush 18
Sharp 18
Mong 15
Terrorterran 12
Mind 11
Killer 11
Dota 2
XaKoH 922
League of Legends
JimRising 685
C9.Mang0597
Counter-Strike
olofmeister277
Super Smash Bros
hungrybox237
Other Games
summit1g8388
ceh9238
Happy194
Pyrionflax151
KnowMe68
Mew2King39
Organizations
Other Games
gamesdonequick29803
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• naamasc226
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos636
Upcoming Events
OSC
2h 44m
ArT vs MindelVK
Cham vs sebesdes
Shameless vs Jumy
Nicoract vs Krystianer
OSC
1d 4h
SOOP
2 days
The PondCast
3 days
Sparkling Tuna Cup
4 days
IPSL
4 days
DragOn vs Sziky
Replay Cast
4 days
Wardi Open
5 days
Monday Night Weeklies
5 days
Liquipedia Results

Completed

Proleague 2026-01-05
WardiTV 2025
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
OSC Championship Season 13
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

Escore Tournament S1: W3
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Thunderfire SC2 All-star 2025
Big Gabe Cup #3
Nations Cup 2026
Underdog Cup #3
NA Kuram Kup
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.