TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How does “min” and “hour” get their values in this C++ code?

1 pointsby shivajikobardanabout 2 years ago
https:&#x2F;&#x2F;imgur.com&#x2F;a&#x2F;UCks0vq<p>Full code here:<p><pre><code> #include&lt;iostream&gt; using namespace std; class Time { public: int hour; int min; Time() { hour=min=0; } Time(int h,int m) { hour=h; min=m; } Time add (Time t) { Time t1; int m=min+t.min; t1.hour=hour+t.hour+m&#x2F;60; t1.min=m%60; return t1; } }; int main() { Time t1; Time t2(8,40); Time t3(5,30); t1=t2.add(t3); cout&lt;&lt;t1.hour&lt;&lt;&quot; &quot;&lt;&lt;t1.min; return 0; } </code></pre> As shown in the figure above, some of my confusions are clear. But what I fail to understand is how &quot;min&quot; and &quot;hour&quot; gets its value from t2(8,40). I am sorry if this is a too basic question, but I didn&#x27;t understand so I am asking. If I am missing any prerequisites to this topic, do tell me about them, that&#x27;d help me more for self learning.

2 comments

bunbun69about 2 years ago
I have no clue what this post is doing here.
评论 #35370473 未加载
评论 #35371965 未加载
pestatijeabout 2 years ago
stackoverflow is your friend
评论 #35371976 未加载