• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:27
CEST 13:27
KST 20:27
  • 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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
StarCraft II 5.0.15 PTR Patch Notes89BSL 2025 Warsaw LAN + Legends Showmatch2Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8
StarCraft 2
General
StarCraft II 5.0.15 PTR Patch Notes Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues #1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy
Tourneys
RSL: Revival, a new crowdfunded tournament series SC2's Safe House 2 - October 18 & 19 Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
ASL20 General Discussion Soulkey on ASL S20 BW General Discussion ASL TICKET LIVE help! :D NaDa's Body
Tourneys
[ASL20] Ro16 Group D BSL 2025 Warsaw LAN + Legends Showmatch [ASL20] Ro16 Group C Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Borderlands 3 Path of Exile Nintendo Switch Thread General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine UK Politics Mega-thread Russo-Ukrainian War Thread Canadian Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
Too Many LANs? Tournament Ov…
TrAiDoS
i'm really bored guys
Peanutsc
I <=> 9
KrillinFromwales
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2327 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 States17252 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 States17252 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 States17252 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
Map Test Tournament
11:00
$500 4v4 Open
WardiTV283
IndyStarCraft 168
Rex94
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Tasteless 550
OGKoka 203
IndyStarCraft 168
Rex 94
ProTech81
StarCraft: Brood War
Britney 21215
Rain 4570
EffOrt 1543
Horang2 1278
actioN 716
Snow 480
Hyuk 474
BeSt 233
Larva 210
Leta 197
[ Show more ]
Pusan 174
Rush 166
Light 102
Barracks 93
Soulkey 92
Mind 84
Hyun 78
Nal_rA 68
ggaemo 56
Liquid`Ret 53
ZerO 50
sorry 38
Sharp 29
Movie 25
ivOry 25
Sea.KH 23
Backho 18
Free 15
soO 11
Sacsri 10
ajuk12(nOOB) 10
JYJ9
Terrorterran 6
Shine 6
Noble 6
SilentControl 5
Dota 2
singsing2714
XcaliburYe169
boxi98141
Counter-Strike
shoxiejesuss378
Heroes of the Storm
Khaldor101
Other Games
olofmeister710
B2W.Neo650
crisheroes420
Hui .191
Lowko79
Mew2King52
NeuroSwarm36
Trikslyr24
EmSc Tv 15
ZerO(Twitch)8
Organizations
Other Games
EmSc Tv 15
StarCraft 2
EmSc2Tv 15
StarCraft: Brood War
CasterMuse 14
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• LUISG 26
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1080
Other Games
• WagamamaTV165
Upcoming Events
Korean StarCraft League
15h 33m
BSL Open LAN 2025 - War…
20h 33m
RSL Revival
22h 33m
Reynor vs Cure
BSL Open LAN 2025 - War…
1d 20h
RSL Revival
1d 22h
Online Event
2 days
Wardi Open
2 days
Monday Night Weeklies
3 days
Sparkling Tuna Cup
3 days
LiuLi Cup
5 days
[ Show More ]
The PondCast
5 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
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

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.