U E D R , A S I H C RSS

AcceleratedC++/Chapter1

Chapter 1

μ€‘μš” μ†ŒμŠ€

~cpp 
// ask for the person's name, and greet the person
#include <iostream>
#include <string>

int main() {
	// ask for the person's name
	std::cout << "Please enter your first name: ";

	// read the name
	std::string name;
	std::cin >> name;

	// write a greeting
	std::cout << "Hello, " << name << "!" << std::endl;
	return 0;
}
----
~cpp 
// ask for the person's name, and generate a framed greeting
#include <iostream>
#include <string>

int main() {

	std::cout << "Please enter your first name: ";
	std::string name;
	std::cin >> name;
	
	// build the message that we intend to write
	const std::string greeting = "Hello, " + name + "!";

	// build the second and fourth lines of the output
	const std::string spaces(greeting.size(), ' ');
	const std::string second = "* " + spaces + " *";

	// build the first and fifth lines of the output
	const std::string first(second.size(), '*');

	// write it all
	std::cout << std::endl;
	std::cout << first << std::endl;
	std::cout << second << std::endl;
	std::cout << "* " << greeting << " *" << std::endl;
	std::cout << second << std::endl;
	std::cout << first << std::endl;

	return 0;
}
----

KeyWords

Variable, Object, definition, local variable, destroy
interface : 객체의 νƒ€μž…μœΌλ‘œ λ¬΅μ‹œμ μœΌλ‘œ 내포 λ˜μ–΄ μžˆλŠ” 것은 μΈν„°νŽ˜μ΄μŠ€λ‘œμ„œ, ν•΄λ‹Ή νƒ€μž…μ˜ 객체에 μ‚¬μš© κ°€λŠ₯ν•œ μ—°μ‚°(operation)λ“€μ˜ 집합을 λ§ν•©λ‹ˆλ‹€. name을 string νƒ€μž…μ˜ λ³€μˆ˜(이름 μžˆλŠ” 객체)둜 μ •μ˜ ν•˜κ²Œ 되며, μš°λ¦¬λŠ” string으둜 ν•  수 μžˆλŠ” λͺ¨λ“  일듀을 name으둜 ν•˜κ³  μ‹Άλ‹€λŠ” λœ»μ„ λ¬΅μ‹œμ μœΌλ‘œ λ‚΄ν¬ν•˜κ²Œ λ©λ‹ˆλ‹€.
μ΄ˆκΈ°ν™”, end-of-file, buffer, flush, overload, const, associativity(결합방식), λ©€λ²„ν•¨μˆ˜, κΈ°λ³Έ λ‚΄μž₯ νƒ€μž…, κΈ°λ³Ένƒ€μž…(built-in type)
----
AcceleratedC++
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:24
Processing time 0.0104 sec