Static members

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
Static members

Static members

#1

投稿記事 by Static members » 13年前

正しく動作させるためには、あとどうすれば良いでしょうか?

Write a class UniqueID such that each instance of this class has a unique identifier (the type of this identifier should be int). The identifier for the first instance of UniqueID should be one, then each new instance will have an identifier with the value one plus the identifier of the previously created object. The identifier can be accessed with the method getID().

Define the class UniqueID in files named UniqueID.h and UniqueID.cpp. To test your code create a file testUniqueID.cpp and type the code below:

コード:

// testUniqueID.cpp

#include <cassert> // for assert()

// COMPLETE: include the proper header

int main(void) {
  UniqueID uid1;
  assert(uid1.getID() == 1);
  
  UniqueID uid2;
  assert(uid2.getID() == 2);
  
  UniqueID uid3;
  assert(uid3.getID() == 3);
  
  return 0;
}

アバター
softya(ソフト屋)
副管理人
記事: 11677
登録日時: 15年前
住所: 東海地方
連絡を取る:

Re: Static members

#2

投稿記事 by softya(ソフト屋) » 13年前

当掲示板は課題の丸投げは禁止させて頂いています。
かならず、ご自分で書いたコードも投稿なさってください。
どうしても分からない時は解き方についてご質問ください。

詳しくは、こちらの方をご覧ください。
「An array-based stack • C言語交流フォーラム ~ mixC++ ~」
http://dixq.net/forum/viewtopic.php?f=3&t=11637
by softya(ソフト屋) 方針:私は仕組み・考え方を理解して欲しいので直接的なコードを回答することはまれですので、すぐコードがほしい方はその旨をご明記下さい。私以外の方と交代したいと思います(代わりの方がいる保証は出来かねます)。

閉鎖

“C言語何でも質問掲示板” へ戻る