• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 21:50
CEST 03:50
KST 10:50
  • 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
[ASL19] Finals Recap: Standing Tall5HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL38Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster14Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? StarCraft Mass Recall: SC1 campaigns on SC2 thread How does the number of casters affect your enjoyment of esports? Esports World Cup 2025 - Final Player Roster
Tourneys
$5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29) WardiTV Mondays SOOPer7s Showmatches 2025
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Help: rep cant save Flash Announces Hiatus From ASL BGH Auto Balance -> http://bghmmr.eu/ [ASL19] Finals Recap: Standing Tall Where did Hovz go?
Tourneys
[Megathread] Daily Proleagues [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread [BSL20] ProLeague LB Final - Saturday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Things Aren’t Peaceful in Palestine Trading/Investing Thread US Politics Mega-thread The Games Industry And ATVI Stop Killing Games - European Citizens Initiative
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread Korean Music Discussion
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
Game Sound vs. Music: The Im…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 556 users

The Big Programming Thread - Page 294

Forum Index > General Forum
Post a Reply
Prev 1 292 293 294 295 296 1031 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 States17246 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 States17246 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 States17246 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 1031 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
HSC 27: Groups A & B
CranKy Ducklings102
Liquipedia
OSC
20:00
Mid Season Playoffs
Gerald vs MojaLIVE!
ArT vs Jumy
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 137
NeuroSwarm 137
RuFF_SC2 125
Vindicta 57
CosmosSc2 49
PiGStarcraft28
StarCraft: Brood War
Artosis 788
Aegong 107
NaDa 61
Icarus 11
Dota 2
monkeys_forever152
capcasts117
League of Legends
JimRising 647
Super Smash Bros
hungrybox777
Heroes of the Storm
Khaldor115
Other Games
summit1g10174
tarik_tv1974
Day[9].tv994
shahzam549
Maynarde144
Mew2King52
Organizations
Other Games
gamesdonequick1564
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Berry_CruncH277
• Hupsaiya 53
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift5068
• Jankos1384
• masondota2757
Other Games
• Day9tv994
Upcoming Events
The PondCast
8h 10m
RSL Revival
8h 10m
ByuN vs Classic
Clem vs Cham
WardiTV European League
14h 10m
Replay Cast
22h 10m
RSL Revival
1d 8h
herO vs SHIN
Reynor vs Cure
WardiTV European League
1d 14h
FEL
1d 14h
Korean StarCraft League
2 days
CranKy Ducklings
2 days
RSL Revival
2 days
[ Show More ]
FEL
2 days
Sparkling Tuna Cup
3 days
RSL Revival
3 days
FEL
3 days
BSL: ProLeague
3 days
Dewalt vs Bonyth
Replay Cast
4 days
Replay Cast
5 days
The PondCast
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025

Upcoming

CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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 © 2025 TLnet. All Rights Reserved.